Last active
February 25, 2018 06:29
-
-
Save noromanba/07f3b4dafbb166692b3e777594edfead to your computer and use it in GitHub Desktop.
disable smooth-scroll for UserScript
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
// ==UserScript== | |
// @name anti smooth-scroll | |
// @namespace http://noromanba.flavors.me | |
// @description disable smooth-scrolling for UserScript | |
// @include http://example.com/DIY | |
// @grant none | |
// @noframes | |
// @run-at document-end | |
// @version 2018.2.25.1 | |
// @homepage https://gist.github.com/noromanba/07f3b4dafbb166692b3e777594edfead | |
// @downloadURL https://gist.github.com/noromanba/07f3b4dafbb166692b3e777594edfead/raw/anti-smooth-scroll.user.js | |
// @license MIT License https://nrm.mit-license.org/2016 | |
// @author noromanba https://noromanba.github.com | |
// @icon https://upload.wikimedia.org/wikipedia/commons/thumb/d/d4/BSicon_uLSTRa.svg/256px-BSicon_uLSTRa.svg.png | |
// ==/UserScript== | |
// Icon (PD by Useddenim) | |
// https://commons.wikimedia.org/wiki/File%3ABSicon_uLSTRa.svg | |
// Devel | |
// https://gist.github.com/noromanba/07f3b4dafbb166692b3e777594edfead | |
// disable in Browser side smooth c.f. | |
// - Chrome family | |
// chrome://flags/#smooth-scrolling | |
// - Firefox family | |
// - https://support.mozilla.org/en-US/questions/1075336#answer-761949 | |
// about:preferences#advanced | |
// - do search "smooth" in searchbox | |
// - direct editing | |
// about:config | |
// general.smoothScroll | true -> false | |
// via | |
// http://stackoverflow.com/questions/29416448/how-to-disable-smooth-scrolling-in-ie11 | |
(() => { | |
'use strict'; | |
const roughen = (ctx) => { | |
// TBD DOMMouseScroll event | |
// TODO throttle/debounce | |
ctx.addEventListener('mousewheel', evt => { | |
//evt.preventDefault(); | |
//evt.stopImmediatePropagation(); | |
window.scrollTo(0, window.pageYOffset - evt.wheelDelta); | |
}, { | |
// Scroll Jank c.f. | |
// https://blog.jxck.io/entries/2016-06-09/passive-event-listeners.html | |
passive: true, | |
}); | |
}; | |
roughen(document.body); | |
// TBD handle other smoothed elements | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment