Jump to content
Search Community

Draggable snap - can it be set after create?

x0b test
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

Is it possible to update the snap array on a draggable instance to something else after creation?

 

Say I have the snap values set to an array, but then later some values in that array change, can I change the old snap array to the new array, therefore updating the snap values?

 

Thanks

Link to comment
Share on other sites

Hi Carl,

 

Thanks, I tried the above syntax but it didn't work. I now realise from your Codepen that appending [0] to the draggable instance var is what I needed to do to access the vars.

 

Thanks a lot

Link to comment
Share on other sites

Just to be clear, yes, the code above refers to to a specific Draggable instance.

 

The CodePen demo uses Draggable.create() which returns an array of Draggables which is why the [0] was necessary. It pulled the first Draggable from the array of Draggables. 

 

Glad you got it working.

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