Ayaf Noneym Posted March 31, 2022 Share Posted March 31, 2022 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 More sharing options...
OSUblake Posted March 31, 2022 Share Posted March 31, 2022 Hi Ayaf, prevX is not from where it started. Try setting it in onPress instead of onDrag. Also, you could also make this sort of thing using our new Observer plugin. Simple demo showing how to drag something. See the Pen BaJwLem by GreenSock (@GreenSock) on CodePen Link to comment Share on other sites More sharing options...
GreenSock Posted April 1, 2022 Share Posted April 1, 2022 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. 👍 1 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