使用jQuery rotate http://code.google.com/p/jqueryrotate/wiki/Examples将对象设置为0度到40度的动画
工作良好,鼠标悬停,鼠标移出-但我需要它自动循环动画之间的两个点,只要它是悬停
需要在client...HELP的午餐前完成!
jQuery("#leafmealonepoint").rotate({
bind:
{
mouseover : function() {
jQuery(this).rotate({animateTo:40})
},
mouseover : function() {
jQuery(this).rotate({animateTo:0})
}
} 更新
好的,我试着像这样使用setInterval --缺少什么?
function move(){
jQuery('#leafmealonepoint').rotate({animateTo:40}, function(){
jQuery(this).rotate({animateTo:0});
});
}
jQuery('#leafmealone').hover(
function() {
hoverInterval = setInterval(move, 1000);
},
function(){
clearInterval(hoverInterval);
}
);进一步更新
jQuery(function(){
var leafmealone
jQuery('#leafmealone').mouseenter(function(){
leafmealone = setInterval(function()
{jQuery('#leafmealonepoint').rotate({animateTo:40},
jQuery('#leafmealonepoint').rotate({animateTo:0}))}, 1000);
}).mouseleave(function(){clearInterval(leafmealone);
});
}); 我遗漏了什么?
发布于 2012-03-01 20:26:24
如果您想在鼠标停留在该元素上时重复动画,则需要一个setInterval(),否则将执行一次动画并在完成时停止,然后鼠标离开将再次执行并再次停止。
编辑:你也有两个鼠标悬停事件,我认为它是输入错误的悬停你需要一个鼠标输出,或直接使用hover()。
发布于 2012-03-01 21:35:18
尝试执行以下操作:
jQuery(function(){
var leafmealone
jQuery('#leafmealone')
.mouseenter(function(){
leafmealone = setInterval(function() {
jQuery('#leafmealonepoint')
.rotate({animateTo:40})
.rotate({animateTo:0});
}, 1000);
})
.mouseleave(function(){
clearInterval(leafmealone);
});
});我不熟悉rotate方法,但动画通常就是这样完成/链接的。
发布于 2012-03-05 19:17:32
以下是解决方案
function leafmealone() {
jQuery('#leafmealonepoint').stop().rotate({ angle:0, animateTo: 40, duration:600, callback: function() {
jQuery('#leafmealonepoint').stop().rotate({ animateTo: 0, duration:600});
}
});
}
jQuery(function() {
jQuery('#leafmealone').hover(function(){
leafmealone();
hoverInterval = setInterval(leafmealone, 1200);
}, function(){
clearInterval(hoverInterval);
});
})
https://stackoverflow.com/questions/9516015
复制相似问题