Skip to content

Instantly share code, notes, and snippets.

@ar-nelson
Created August 20, 2019 17:44
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ar-nelson/9d545c51501ae4527a5c7dd920cab15b to your computer and use it in GitHub Desktop.
Save ar-nelson/9d545c51501ae4527a5c7dd920cab15b 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 <adam@nels.onl>
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();
@thblckjkr
Copy link

Works great!!

Do you know if is there any way to make firefox load this script every time I open up figma?

@ar-nelson
Copy link
Author

@thblckjkr It's a Greasemonkey script, so just install the extension: https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/

Then select "New user script" from the extension's menu, and paste the contents of this script into it. The @match https://www.figma.com/* line will make it autoload on all Figma pages.

@guifsdev
Copy link

guifsdev commented Aug 12, 2021

Hi,
Is there any update for this script to work for Firefox 91 as of august 2021?
My scroll speed is now extremely high, jumping 10x each turn.
Turning of the script makes is too slow also.
Changing the values of MULTIPLIER_X and MULTIPLIER_Y does not produce any effect even refreshing.
Any help appreciated.

@guifsdev
Copy link

I just set MULTIPLIER_X and Y to 0.5 and now it`s a bit better.

@thblckjkr
Copy link

@guifsdev This seems like a problem with firefox new defaults.

There was a post en reddit that seems to be the same as your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment