如何将Mootools代码转换为jQuery代码以向下滑动,然后滚动到#current?
我想知道 Mootools 是否有像 onStart 和 onComplete 这样的 API,这让我很好奇我从哪里获得这些 jQuery API...有一个示例脚本:
var slidez = null;
function closeOpen(ref) {
//return
if (ref != slidez && slidez.wrapper.offsetHeight > 0) {
slidez.slideOut();
}
}
window.addEvent('domready', function() {
slidez = new Fx.Slide('hello_content', {
duration: 1000,
onStart: function(request) {
if (this.wrapper.offsetHeight == 0) {
closeOpen(slidez);
}
},
onComplete: function(request) {
if (this.wrapper.offsetHeight > 0) {
new Fx.Scroll(window).toElement($('toggle_content'));
}
}
});
$('toggle_content').addEvent('click', function(e) {
e = new Event(e);
slidez.toggle();
e.stop();
});
slidez.hide();
});
我尝试将它转换为 jQuery 代码,但有时它会失败,我浪费了时间,我需要这里的帮助...
提前致谢!
I was wondering there type of API like onStart and onComplete from Mootools, it makes me curious where i get those APIs for jQuery... there an example script:
var slidez = null;
function closeOpen(ref) {
//return
if (ref != slidez && slidez.wrapper.offsetHeight > 0) {
slidez.slideOut();
}
}
window.addEvent('domready', function() {
slidez = new Fx.Slide('hello_content', {
duration: 1000,
onStart: function(request) {
if (this.wrapper.offsetHeight == 0) {
closeOpen(slidez);
}
},
onComplete: function(request) {
if (this.wrapper.offsetHeight > 0) {
new Fx.Scroll(window).toElement($('toggle_content'));
}
}
});
$('toggle_content').addEvent('click', function(e) {
e = new Event(e);
slidez.toggle();
e.stop();
});
slidez.hide();
});
I tried to convert it to jQuery code, but sometimes it failed and i wasted of my time, i needed a help here...
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
jQuery 动画并不像 mootools 中那样创建为对象,而只是在元素上调用的方法。没有 onstart 事件 - 您只需在调用动画方法之前调用任何 onstart 代码即可。 oncomplete 的 jquery 等价物是动画方法的回调参数。动画完成时调用回调。
jQuery animations are not created as objects as in mootools, but rather are just methods called on elements. There is no onstart event - you would just call any onstart code before you call the animation method. The jquery equivelant of oncomplete is the callback argument to the animation method. The callback is called when the animation is complete.