I would like to use jQuery to move an object. I would like to animate this movement to move the element from its current vertical position to a new vertical position, as measured from the upper edge of its parent element.
To do this animation right now, I do the following:
var b = $(".another_object").position();
$(".object_to_move").animate({top:b.top},200);
This animates great, but the animation always has the object beginning at top of the parent (ie from top:0px;) to the desired location.
Does anyone know how I can alter this or use another function to slide from the current position to the desired one?
var b = $(".another_object").position();
$(".object_to_move").animate({top:"+" + b.top},200);
Prefix it with a plus, and it will start where it currently is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With