Lawston Posted March 8, 2021 Share Posted March 8, 2021 I wish to save the position of draggable components within an SVG to a JSON file so the components can be restored to their position at a later time. Has anyone a codepen example (no jQuery) of how this can be done with gsap? Link to comment Share on other sites More sharing options...
ZachSaucier Posted March 8, 2021 Share Posted March 8, 2021 Hey Lawston and welcome to the GreenSock forums. Related thread: Here's a demo to start from: See the Pen wvoYJGg?editors=0010 by GreenSock (@GreenSock) on CodePen Inside of the onDragEnd callback function you can create the JSON format using that information and then save it to wherever you need it to be. When the page loads, you get the data from that location and then use gsap.set() to put it in that spot. Link to comment Share on other sites More sharing options...
Lawston Posted March 8, 2021 Author Share Posted March 8, 2021 Great input, Zach. This works great! Thanks much for the prompt response! 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