Ivan Mocs Posted February 17 Share Posted February 17 I'm looking for an example of an obeserver with type "wheel" but I don't know how to do it. See the Pen rNRPRjN by adeivan (@adeivan) on CodePen Link to comment Share on other sites More sharing options...
GreenSock Posted February 17 Share Posted February 17 I'm not quite sure what you're trying to do, but here's a fork that shows the "wheel" events triggering the onChangeY() callback on the Observer when you wheel while over the box: See the Pen RwdvdVL?editors=1010 by GreenSock (@GreenSock) on CodePen If you're trying to sense touchmove events, you can use type "touch", but if you're trying to do multi-touch detection and gestures, that's not really what Observer is for. Link to comment Share on other sites More sharing options...
Ivan Mocs Posted February 17 Author Share Posted February 17 7 minutes ago, GreenSock said: I'm not quite sure what you're trying to do, but here's a fork that shows the "wheel" events triggering the onChangeY() callback on the Observer when you wheel while over the box: If you're trying to sense touchmove events, you can use type "touch", but if you're trying to do multi-touch detection and gestures, that's not really what Observer is for. maybe like on this site, can be swiped with a trackpad : https://amie.so/recap Link to comment Share on other sites More sharing options...
GreenSock Posted February 17 Share Posted February 17 Maybe this will help: See the Pen abMXMYm by GreenSock (@GreenSock) on CodePen Link to comment Share on other sites More sharing options...
Ivan Mocs Posted February 17 Author Share Posted February 17 4 minutes ago, GreenSock said: Maybe this will help: yep, like this! but the movement is inverted, when I swipe left, the object moves right, likewise when up, the object moves down, I changed + to - in this code and it seems to fix the mistake const myObserver = Observer.create({ type: "wheel", wheelSpeed: 10, onChange(self) { xTo(getter("x") - self.deltaX); yTo(getter("y") - self.deltaY); } }); a suggestion from me, maybe you can create a new option for draggables like the one at https://ilyashubin.github.io/scrollbooster/ which is emulateScroll Thank you btw Link to comment Share on other sites More sharing options...
Ivan Mocs Posted February 17 Author Share Posted February 17 9 minutes ago, Ivan Mocs said: yep, like this! but the movement is inverted, when I swipe left, the object moves right, likewise when up, the object moves down, I changed + to - in this code and it seems to fix the mistake const myObserver = Observer.create({ type: "wheel", wheelSpeed: 10, onChange(self) { xTo(getter("x") - self.deltaX); yTo(getter("y") - self.deltaY); } }); a suggestion from me, maybe you can create a new option for draggables like the one at https://ilyashubin.github.io/scrollbooster/ which is emulateScroll Thank you btw and this can lead to new problems, such as shifting without knowing the bounds. Link to comment Share on other sites More sharing options...
Solution GreenSock Posted February 17 Solution Share Posted February 17 Invert the wheelSpeed to a negative value then. And for bounds, you will need to apply JavaScript logic to calculate those and clamp the numbers in the callback. 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