JSFiddle - React, Tailwind, and code Playground

by hamix

HTML

<button>jump!</button>

CSS

html, body {
    height: 8000px;
}

JavaScript

$('html, body').bind('DOMMouseScroll mousewheel MozMousePixelScroll', function(e) {
    var scrollTo = 0;

  if (e.type == 'mousewheel') {
      scrollTo = (e.originalEvent.wheelDelta * -1);
  }
  else if (e.type == 'DOMMouseScroll') {
      // scrollTo = 20 * e.originalEvent.detail; // turns out, this sometimes works better as expected...
      scrollTo = e.originalEvent.detail;
  }

  if (scrollTo > 0) {
    e.preventDefault();
    return false;
  }
});

$('button').click( function() { $('html, body').scrollTop(1000) } );