Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
fionchadd

Draggable snap only affecting X value

Go to solution Solved by GreenSock,

Recommended Posts

Hi there, 

 

I'm trying to work with Draggable at the moment and I'm having an issue with the snap function. I'm trying to get the item to return to its original position after it's been thrown; currently the snap value seems to be affecting the X value but not the Y value and I'm not really sure why? 

 

Any advice you can give would be greatly appreciated! 

 

Thanks

 

Hannah

See the Pen XWgZXgL by fionchadd (@fionchadd) on CodePen

Link to comment
Share on other sites

Welcome to forums @fionchadd

 

Standby while we look into this issue. In the meantime you can use a function for snap.

snap:
{
  x: () => 0,
  y: () => 0
},

 

 

Link to comment
Share on other sites

  • Solution

That was related to an obscure bug in InertiaPlugin related to Array-based end values which should be fixed in the next release. Preview on CodePen at https://assets.codepen.io/16327/InertiaPlugin.min.js (clear your cache first)

 

I'd also strongly recommend just using one timeline and restart() it in the onDragEnd because it'll be far more efficient than re-creating all those tweens every time. You can use defaults on the timeline to reduce your code too: 

See the Pen abwqVVa?editors=0010 by GreenSock (@GreenSock) on CodePen

 

  • Like 2
Link to comment
Share on other sites

Hi Jack, 

 

ah that’s amazing, thanks so much for the advice! I’m still pretty new to gsap so that’s super helpful to know. Also cant believe I found a real life bug lol, I was convinced I was doing something wrong 😅

 

thanks for your help!

 

hannah

  • Like 2
Link to comment
Share on other sites

Congratulations Hannah! Top tier bug hunting!

0f0d0fd95624ae563c98504801ec3f1f_preview_featured.jpeg

  • Like 1
  • Haha 2
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.
×