1
0
mirror of https://github.com/sjlongland/tornado-gallery.git synced 2025-09-13 08:42:23 +10:00
tornado-gallery/templates/wheellib.js
Stuart Longland 1706852291
Port ClearSilver templates to Tornado.
This is a first stab, and yes, things are *UGLY*, particularly the
JavaScript, which was written almost 10 years ago.  As such, it
pre-dates versions of IE that play nice with web standards, Promises and
lots of other advancements.

My knowledge of JavaScript has also greatly improved since then. :-)
2018-03-25 13:40:02 +10:00

26 lines
659 B
JavaScript

/* Source: http://adomas.org/javascript-mouse-wheel/ */
function wheel(event){
var delta = 0;
if (!event) /* For IE. */
event = window.event;
if (event.wheelDelta) { /* IE/Opera. */
delta = event.wheelDelta/120;
if (window.opera)
delta = -delta;
} else if (event.detail) { /** Mozilla case. */
delta = -event.detail/3;
}
if (delta)
wheelHandler(delta);
if (event.preventDefault)
event.preventDefault();
event.returnValue = false;
}
if (window.addEventListener)
/** DOMMouseScroll is for mozilla. */
window.addEventListener('DOMMouseScroll', wheel, false);
else
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = wheel;