Skip to content

Instantly share code, notes, and snippets.

@Dionid
Last active August 29, 2015 14:14
Show Gist options
  • Save Dionid/116ceab955e90996aa19 to your computer and use it in GitHub Desktop.
Save Dionid/116ceab955e90996aa19 to your computer and use it in GitHub Desktop.
MOUSEWHEEL JQUERY Coffee
$.fn.mousewheel = (handler)->
target = $(@)[0]
if target.addEventListener
target.addEventListener("mousewheel", handler, false);
target.addEventListener("DOMMouseScroll", handler, false);
else
target.attachEvent("onmousewheel", handler);
@
// DIRECTION
e = window.event || e;
delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail || -e.originalEvent.detail)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment