【发布时间】:2012-03-19 22:28:04
【问题描述】:
使用 jQuery 旋转 http://code.google.com/p/jqueryrotate/wiki/Examples 将对象从 0 度设置为 40 度
在鼠标悬停、鼠标悬停时可以正常工作 - 但我需要它在两点之间自动循环动画,只要它悬停
需要在午餐前为客户完成...帮助!
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);
});
});
我错过了什么?
【问题讨论】:
-
据我所知hoverInterval不是全局变量,所以无法清除
标签: jquery jquery-animate rotation mouseover repeat