-
-
Save dav11d/64c193c94542b584eb26d54d44a43a5c to your computer and use it in GitHub Desktop.
on mousewheel vanilla js scroll horizontally #js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('wheel', function(e) | |
{ | |
if(e.type != 'wheel') | |
{ | |
return; | |
} | |
let delta = ((e.deltaY || -e.wheelDelta || e.detail) >> 10) || 1; | |
delta = delta * (-300); | |
document.documentElement.scrollLeft -= delta; | |
e.preventDefault(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment