FrEZ Posted February 25, 2023 Share Posted February 25, 2023 As you can see, when you scroll down with mouse, it works perfectly, but on touch you have to touch the opposite direction. Any idea how to make it when on mobile, or on touch to switch onUp and onDown? See the Pen oNdNLxL by GreenSock (@GreenSock) on CodePen Link to comment Share on other sites More sharing options...
FrEZ Posted February 25, 2023 Author Share Posted February 25, 2023 I saw that you can check Observer.isTouched, don't know if that's the most efficient way, but if it is, can I get an example of it in use? Link to comment Share on other sites More sharing options...
GreenSock Posted February 26, 2023 Share Posted February 26, 2023 I just updated that demo to do what I think you wanted. Basically, I set wheelSpeed: -1 to invert the wheel direction and then flip-flopped the onUp/onDown and made a couple of other minor tweaks. See the Pen oNdNLxL?editors=0010 by GreenSock (@GreenSock) on CodePen Is that working the way you hoped? Link to comment Share on other sites More sharing options...
FrEZ Posted February 26, 2023 Author Share Posted February 26, 2023 I see that you have managed to achieve it. Is it possible for me to get the old and new code to see what you have changed to make it work, as just switching wheelspeed didn't do it for me, as I am not using a separate scrolltrigger to enable Observer. Cheers! Link to comment Share on other sites More sharing options...
Solution GreenSock Posted February 26, 2023 Solution Share Posted February 26, 2023 I added the onPress to preventDefault() on the touchstart, and just flip-flopped the onUp/onDown logic. // old onUp: () => !animating && gotoPanel(currentIndex - 1, false), onDown: () => !animating && gotoPanel(currentIndex + 1, true), // new onUp: () => !animating && gotoPanel(currentIndex + 1, true), onDown: () => !animating && gotoPanel(currentIndex - 1, false), wheelSpeed: -1, 2 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