JSFiddle - React, Tailwind, and code Playground
CSS
html, body{
height: 100%;
}
JavaScript
var container = $('body');
addMouseWheelHandler();
function MouseWheelHandler(e) {
// cross-browser wheel delta
e = window.event || e;
var delta = Math.max(-1, Math.min(1,
(e.wheelDelta || -e.deltaY || -e.detail)));
console.log(e.wheelDelta || -e.deltaY || -e.detail);
console.log(delta);
return false;
}
/**
* Adds the auto scrolling action for the mouse wheel and tackpad.
* After this function is called, the mousewheel and trackpad movements will scroll through sections
*/
function addMouseWheelHandler() {
if (container.get(0).addEventListener) {
container.get(0).addEventListener('mousewheel', MouseWheelHandler, false); //IE9, Chrome, Safari, Oper
container.get(0).addEventListener('wheel', MouseWheelHandler, false); //Firefox
} else {
container.get(0).attachEvent('onmousewheel', MouseWheelHandler); //IE 6/7/8
}
}