-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only need swipeUp & swipeDown event on Trackpads / mousewheels #34
Comments
I am not sure I understand your question properly - if you only want to add a callback to
But if you only want a library to detect scroll intents, then lethargy should be sufficient. |
Thanks for the quick answer, wow– I tried only using lethargy.js and fiddled around with the options and still get multiple events fired per swipe. The snipped you just posted is what I am trying at the moment, but can't get smartscroll to work I guess? When initiating smartscroll I get the following error:
|
It would be great to only use lethargy.js; but I just don't understand how you did "the green dots" in the demo. Here is what I have with
$(window).bind('mousewheel DOMMouseScroll wheel MozMousePixelScroll', function(e){
e.preventDefault()
e.stopPropagation();
if(lethargy.check(e) !== false) {
console.log(lethargy.check(e));
if (lethargy.check(e) < 0) nextPanel();
else if (lethargy.check(e) > 0) prevPanel();
}
}); (the lethargy demo doesn't fire intents on very subtle swipe downs, which I'd like to have) |
Lethargy doesn't work for the first 15 events or so. This is because it must hold a cache of past events to determine whether the next event is likely to be an intent or not. If you see real carefully, the first 15 events would all be green, only when the initial 15-unit cache has been filled would lethargy work properly. This is not normally an issue because a single scroll / swipe fires 10-20 events anyways, so the cache fills up quickly. Regarding your console output, you're likely using a trackpad which has the following profile: So it's unlike other trackpads which has a decay: Lethargy works by detecting decay in the You can wrap lethargy in your own debounce/throttle function. For example, if you know that the slide animations would take at least 1 second to complete, then debounce/throttle it for 1 second. See The Difference Between Throttling and Debouncing for more information. FYI, if you use a mouse wheel, you would get the following console output in the demo. |
Okay, thanks for the info; But I get the following error going with your approach in post 2 of this issue
|
Regarding very subtle swipes, you can change the You can also play around with the |
Did you set the |
So far I'm not setting it at all; I don't want smartscroll to handle the sections and animations etc. for me– is there a way to only use the events? |
If you just want to use the events, then you should only use Lethargy. Instead of just |
I am desperately looking for a way to detect a swipe on trackpads and "a single flick" on mousewheels.
Unfortunately I can't find a way to extract these bits out of your code and don't see a way to only use these events from your library.
Of course I have EmitterEvents.js and lethargy.js installed aswell.
Could you please tell me a way to callback only on swipeUp / swipeDown without doing altering anything else?
The text was updated successfully, but these errors were encountered: