鼠标滚轮绑定上的JQuery animate()
JQuery animate() on mousewheel bind
我不明白我做错了什么。这非常好:
$('body').bind('mousewheel', function(e){
if(e.originalEvent.wheelDelta < 0) {
//scroll down
//console.log('Down');
$(".spacer_top_panel").css({"height": "90px"});
$(".spacer_top_panel nav").css({"margin": "15px auto"});
} else {
//scroll up
//console.log('Up');
$(".spacer_top_panel").css({"height": "140px"});
$(".spacer_top_panel nav").css({"margin": "45px auto"});
}
});
然而,当我将.css更改为.animate时,它只在向下滚动时起作用,但在再次向上滚动时对象将不起作用。
$('body').bind('mousewheel', function(e){
if(e.originalEvent.wheelDelta < 0) {
//scroll down
//console.log('Down');
$(".spacer_top_panel").animate({height:'90px'});
$(".spacer_top_panel nav").animate({margin:'15px auto'});
} else {
//scroll up
//console.log('Up');
$(".spacer_top_panel").animate({height:'140px'});
$(".spacer_top_panel nav").animate({margin:'45px auto'});
}
});
你知道我在这里做错了什么吗?我想问题很明显,但我就是看不出来。感谢您的帮助。
使用stop();
中断一个动画并切换到另一个
$('body').bind('mousewheel', function(e){
if(e.originalEvent.wheelDelta < 0) {
//scroll down
//console.log('Down');
$(".spacer_top_panel").stop().animate({height:'90px'});
$(".spacer_top_panel nav").stop().animate({margin:'15px auto'});
} else {
//scroll up
//console.log('Up');
$(".spacer_top_panel").stop().animate({height:'140px'});
$(".spacer_top_panel nav").stop().animate({margin:'45px auto'});
}
});
相关文章:
- 可以'使用jQuery animate时无法看到动画
- 如何使用jquery animate来回移动多个元素
- jQuery animate()函数没有't设置动画
- JQuery.animate();不以固定高度工作
- 有没有一种方法可以用步骤递归调用jQuery animate()
- jquery animate无法正常工作
- JQuery.animate()菜单幻灯片返回
- jQuery animate只在单击时工作一次
- 如何在不使用css转换的情况下将jQuery animate与css3属性相结合
- Implementation of jQuery 'animate' with Meteor
- jQuery Animate 在创建图库滑块时不起作用
- jQuery animate 会中断空格键滚动
- Jquery Animate on IE makes error
- 使用 jQuery animate 时绘制一个又一个对象的线条
- Jquery animate 不能与 IE 一起使用 - 什么也没发生
- 只执行一次jquery animate
- 第一个jQuery.animate()不工作
- 使用jquery animate()在文本上实现反弹效果
- jquery .animate 回调自动执行
- jQuery+Animate.css动画只工作一次,动画不会重置