Jump to content
Search Community

Is it possible to move an element to another by relative position?

kfconeone test
Moderator Tag

Recommended Posts

For example, can I use like:

gsap.to("#el",{localPosition: "#destinationEl", duration: 1})

then "#el" will move to "#destinationEl". 

 

I Know I could calculate the distance between two elements but it's too bothersome.

does gsap support this feature? 

Link to comment
Share on other sites

Hello @kfconeone

 

If I understand correctly, that would be an ideal usecase for the FLIP Plugin.

 

It's not quite as simple as that pseudo-code-snippet of yours, but still and especially with regard to the calculations you mentioned you would have to do yourself, it makes things a whole lot easier than having to do things manually.

 

Here is an example, click anywhere to see the flipping happen.

 

See the Pen WNdrPJW by akapowl (@akapowl) on CodePen

 

 

 

You'll find lots more in the docs

 

https://greensock.com/docs/v3/Plugins/Flip/

 

and over on Codepen

 

https://codepen.io/collection/AEkJmd

https://codepen.io/collection/nqvwmG

 

Have fun trying it out! Happy flipping!

 

  • Like 6
Link to comment
Share on other sites

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...