Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aalfiann/3250489924aa73cb7925ac08cac9268d to your computer and use it in GitHub Desktop.
Save aalfiann/3250489924aa73cb7925ac08cac9268d to your computer and use it in GitHub Desktop.
Greasemonkey script to fix slow Figma mouse wheel scrolling in Firefox on Linux
// ==UserScript==
// @name Figma Mouse Wheel Speed Fix
// @namespace https://adam.nels.onl
// @match https://www.figma.com/*
// @grant none
// ==/UserScript==
// Mouse wheel scrolling in Figma on Firefox + Linux is unbearably slow.
//
// This script catches all mouse wheel events on the main canvas,
// then re-fires them with the deltaX/deltaY increased by a multiplier.
//
// - Adam Nelson <[email protected]>
const MULTIPLIER_X = 30;
const MULTIPLIER_Y = 10;
function speedUp(ev) {
if (!ev.isTrusted) return true; // Prevent recursion.
const { clientX, clientY, screenX, screenY, shiftKey, ctrlKey, altKey } = ev;
const newEv = new WheelEvent('wheel', {
bubbles: true,
cancelable: true,
view: window,
clientX,
clientY,
screenX,
screenY,
ctrlKey,
shiftKey,
altKey,
deltaX: ev.deltaX * MULTIPLIER_X,
deltaY: ev.deltaY * MULTIPLIER_Y
});
ev.preventDefault();
ev.stopPropagation();
ev.target.dispatchEvent(newEv);
return false;
}
// Wait for the main canvas to show up.
function addCanvasEvent() {
const canvas = document.querySelector('.view > canvas');
if (canvas != null) canvas.addEventListener('wheel', speedUp);
else setTimeout(addCanvasEvent, 500);
}
addCanvasEvent();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment