How to disable the multiple scroll effect in osx and the scroll event of the scroll once per scroll

I need to organize navigation like jquery.fullPage: when I scroll once, I move on to the next section.

I tried to use jquery.mousewheel for it, but it doesn’t work on MacOS with a touchpad or trackpad or APPLE Magic Mouse: it scrolls several slides by one scroll.

I tried using this solution: https://github.com/jquery/jquery-mousewheel/issues/36#issuecomment-67648897

It works fine in Chrome, but it doesn't work in FF and has bugs in Safari.

This is a simple demonstration of the problem: http://jsfiddle.net/ss5LueLx/13/

$slider.on('mousewheel', function(event) { if (event.deltaY>0) { slider.prevSlide(); } else { slider.nextSlide(); } }); 
+5
source share
1 answer

I tested this statement in my SeaMonkey browser and it fails.

 var delta = e.type == 'mousewheel' ? e.originalEvent.wheelDelta * -1 : 40 * e.originalEvent.detail; 

Just in case, I looked at deltaY and it works: +1 in one direction and -1 in the other, as you defined in the other two implementations that you have.

 console.log(e.deltaY); // view console in FireBug 

Looking at the event structure in Firebug, I see that the event type is "mousewheel", and yet I do not see the wheelData field in the originalEvent.

And although there is a detail field, but it remains at zero.

I would suggest that you try to move to the next point only after you reach +/- 3. I would suggest something like this to accomplish this feat:

 // somewhere, initialize to zero var current_position = 0; // on mousewheel events current_position += e.deltaY; // you had ax 40 which would indicate that the limit is about 120 / 40 // if 3 is too small, you can always increase it to 5 or event 10... if(current_position <= -3) { slider.nextSlide(); current_position = 0; } else if(current_position >= 3) { slider.prevSlide(); current_position = 0; } 

Otherwise, you can verify that your allowScroll flag allowScroll working properly. I don't program objects this way, so I'm not sure if this is correct or not. (I use prototype syntax, which is useful if you want to extend classes.)

0
source

All Articles