Skip to content

Instantly share code, notes, and snippets.

@davehax
Last active August 20, 2019 13:56
Show Gist options
  • Select an option

  • Save davehax/6b6ab82ce1169df7f287823775841180 to your computer and use it in GitHub Desktop.

Select an option

Save davehax/6b6ab82ce1169df7f287823775841180 to your computer and use it in GitHub Desktop.
// Works on desktop browsers only
if (navigator.userAgent.match(/Trident\//) || navigator.userAgent.match(/Edge\//)) {
document.body.addEventListener("mousewheel", function(evt) {
evt.preventDefault();
var wd = evt.wheelDelta;
var csp = window.pageYOffset;
window.scrollTo(0, csp - wd);
});
// If the code block above doesn't work, please try attaching the event to the window like so:
// window.addEventListener("mousewheel", function(evt) {
// evt.preventDefault();
// var wd = evt.wheelDelta;
// var csp = window.pageYOffset;
// window.scrollTo(0, csp - wd);
// });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment