Trackpads, prevent multiscroll

4

I have a little problem with trackpads (at least with MAC mice).

I show the following current code:

$("body").on("mousewheel", function(e) {
    var body = $(this);
    //If the body doesn't have the "animating" class, we add it and do the animations here,
    //If it has it, it doesn't does anything until it finishes animating
    if(!body.hasClass("animating")) {
        body.addClass("animating");
        //MY CODE GOES HERE
        ...
        setTimeout(function() {
            body.removeClass("animating");
        }, 1500);
    }
});

What I do with this piece of code, is that when someone scrolls the page, I show some animations, and until they do not finish, it prevents them from scrolling again.

This works like a finger ring in conventional mice with wheels, but not with trackpads. If I scroll quickly, once you have finished the animations (and delete the "animating" class after the 1500ms of the setTimeout), scroll back and enter the condition if , even if you do not touch the trackpad at all. It's as if the trackpad leaves a lot of scrolls in the stack for a period of time depending on how fast it has been scrolling.

Is there any way to prevent this behavior?

I add to clear a little thing. The page occupies 100% of the screen, that is, it does not have vertical scroll, therefore, the function on("scroll", function()) does not detect the scroll. p>     

asked by Cheshire 23.03.2017 в 16:47
source

0 answers