Jump to content
Search Community

Animating into another element.

fatnjazzy
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Posted

Hi,

Is it possible to do dom manipulation and animate one item into another?

when I do drag and drop, I need to item to sit in the DOM of the drop area....
Possible?

Thanks

See the Pen MBQJGB by fatnjazzy (@fatnjazzy) on CodePen.

Posted

Here is how you can do it. First you need to record position of your element using getBoundingClientRect and then append it inside your target container and reset your target element's x and y translate values. Now again record the position using getBoundingClientRect and use both position values to calculate the difference. Then use the from Tween and animate it to the position based on difference.

 

See the Pen mjXRar?editors=0010 by Sahil89 (@Sahil89) on CodePen.

 

  • Like 4
Posted

Thank you! Im testing it right now.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...