kfconeone Posted March 18, 2022 Share Posted March 18, 2022 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 More sharing options...
akapowl Posted March 18, 2022 Share Posted March 18, 2022 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! 6 Link to comment Share on other sites More sharing options...
GreenSock Posted March 18, 2022 Share Posted March 18, 2022 Yep, Flip makes that pretty easy. Also this function can be useful if you don't want to use Flip: https://greensock.com/docs/v3/Plugins/MotionPathPlugin/static.getRelativePosition() Good luck! 3 Link to comment Share on other sites More sharing options...
kfconeone Posted March 19, 2022 Author Share Posted March 19, 2022 I didn't figure out I could do this by Flip, to be honest, I just skimmed the Flip when this plugin released. And it seems like gsap have some interesting methods can be used like getRelativePosition(). Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now