Offset animation with jquery

I'm doing it:

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

What I would like to do is revitalize the move. So I did:

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

But this is not the place. Although it was normal with the first version.

What am I doing wrong?

thanks for the help

+3
source share
2 answers

I am not an expert, but I think that animate () and css () can change the offset relative to the parent .. like position (), and offset () gives the offset from the whole document. maybe that confuses?

+4
source

Try

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

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

+2
source

Source: https://habr.com/ru/post/1751781/


All Articles