public
Created

prevent wheel events

  • Download Gist
prevent-wheel.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
// require jquery
 
jQuery(function(){
 
var WheelControl = {
_enabled: true,
 
enable: function(enabled) {
Aiming.WheelControl._enabled = enabled;
},
 
onMouseWheel: function(event) {
if (!Aiming.WheelControl._enabled) {
if (!event) {
event = window.event;
}
if (event.preventDefault) {
event.preventDefault();
}
event.returnValue = false;
}
}
}
 
if (window.addEventListener) {
window.addEventListener('DOMMouseScroll', WheelControl.onMouseWheel, false);
}
window.onmousewheel = document.onmousewheel = WheelControl.onMouseWheel;
 
$('.prevent-wheel').hover(
function() { WheelControl.enable(false) },
function() { WheelControl.enable(true) }
)
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.