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.)
source share