开发者

Animate offset with jquery

开发者 https://www.devze.com 2023-01-04 23:02 出处:网络
I\'m doing this : source.offset({ top: top + 10 + (current)*60 , left: left + 10 }); What I would like to do is to animate the m开发者_运维百科ove. So I\'ve done :

I'm doing this :

source.offset({ top: top + 10 + (current)*60 , left: left + 10 });

What I would like to do is to animate the m开发者_运维百科ove. So I've done :

source.animate({left: left + 10, top:top + 10 + (current)*60}, 500, function() {    // Animation complete.});

But it's not going to the right place. Although with the first version it was ok.

What am I doing wrong ?

Thanks for your help


I'm no expert but I think animate() and css() can change offset relative to the parent.. like position() while offset() gives you the offset from the whole document.. maybe thats what confuses?


Try

$("#source").animate({left: (left + 10), top:(top + 10 + ((current)*60))}, 500, function()
 { //comments });

For more info, see http://forum.jquery.com/topic/offset-with-animate

0

精彩评论

暂无评论...
验证码 换一张
取 消