Jump to content
Search Community

Saving SVG component positions as JSON string (no jQuery)

Lawston test
Moderator Tag

Recommended Posts

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

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

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