我想在页面上脉动一个div (向下箭头)。当用户单击向下箭头时,另一个div滑行切换,脉冲动画停止。当向下箭头再次被点击时,另一个div向上滑动,向下箭头开始再次跳动。
这里有一个类似的想法,但脉搏只是停止了:
jQuery(".pulse").effect("pulsate", { times:1000 }, 2000).click(function(){
jQuery(this).stop(true, true);
});发布于 2013-10-26 09:13:53
据我所知,.effect()方法不会无限期地继续动画,因此每次动画结束时都需要继续调用它,也许是从函数内部触发动画,函数也是作为完整回调提供的。
至于在显示另一个div时停止它,然后重新启动它,您可以使用一个标志来决定切换的方式,可能如下所示:
function keepPulsing() {
$pulse.effect("pulsate", 500, keepPulsing);
}
var pulsing = true,
$pulse = jQuery(".pulse").click(function(){
if (pulsing) {
jQuery(".other").slideDown();
jQuery(this).stop(true, true).css("opacity",1);
} else {
jQuery(".other").slideUp();
keepPulsing();
}
pulsing = !pulsing;
});
keepPulsing();https://stackoverflow.com/questions/19604681
复制相似问题