JSFiddle - React, Tailwind, and code Playground
HTML
<body class="horizontal">
JavaScript
// Horizontal scrolling - Pure Javascript solution
// http://www.dte.web.id/2013/02/event-mouse-wheel.html
(function() {
if(document.body.className === 'horizontal') {
alert('It exists');
function scrollHorizontally(e) {
e = window.event || e;
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
// Scroll to the left or right in `document.documentElement` and `document.body`
document.documentElement.scrollLeft -= (delta * 75); // Multiplied by 75
document.body.scrollLeft -= (delta * 75); // Multiplied by 75
e.preventDefault();
}
if (window.addEventListener) {
window.addEventListener('mousewheel', scrollHorizontally, false); // IE9, Chrome, Safari, Opera
window.addEventListener('DOMMouseScroll', scrollHorizontally, false); // Firefox
} else {
window.attachEvent('onmousewheel', scrollHorizontally); // IE 6/7/8
}
};
})();