Jump to content
Search Community

onDragEnd() is setting defined x position but without transition.

Ayaf Noneym test
Moderator Tag

Recommended Posts

I am trying to make something like thisI want to set specific position of x if value of drag on x axis is greater than defined number everything is working just fine but without transition or I can say without bounceEffect .

 

Additionally I also want to reset position of draggable element on focusLost

See the Pen zYPWWPj by NikalLawde (@NikalLawde) on CodePen

Link to comment
Share on other sites

The only problem with leaning on the delta values only is that you can get drift, like if the user's mouse goes off the edge of the viewport/iframe which is why I prefer to measure from the onPress and tap into the startX/startY: 

 

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

 

A little bit more complicated, but it prevents the drift. 👍

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