AsKadir Posted September 20, 2021 Share Posted September 20, 2021 Hello, I made a horizontal container with items inside, it's draggable, scrollable and infinite. It's working great, except dragging not working as excepted for touch devices. I don't have any errors and don't know what to do. Can someone help me, please? I'm sure this demo will help a lot people. See the Pen VwWXBJO by ChicagoJostik (@ChicagoJostik) on CodePen Link to comment Share on other sites More sharing options...
Solution OSUblake Posted September 21, 2021 Solution Share Posted September 21, 2021 Hi AsKadir! Callbacks don't pass in the position. They pass in the event, and you're just grabbing event.x which is the same as event.clientX, which might be undefined with touch. You should get the position provided by Draggable. onDragStart() { touchStart = this.x; }, onDrag() { touchX = this.x; scrollY += (touchX - touchStart) * 2.5; touchStart = touchX; }, You could also clean up your code your using quickSetter and gsap.ticker instead of requestAnimationFrame. And GSAP has a lerp utility function. 4 1 Link to comment Share on other sites More sharing options...
AsKadir Posted September 21, 2021 Author Share Posted September 21, 2021 @OSUblake Hi Blake! Thanks a lot! I really appreciate your help!!! 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