Figma scroll fix

https://forum.figma.com/t/horizontal-scroll-on-the-layers-panel/643/54

目前為 2023-01-19 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Figma scroll fix
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  https://forum.figma.com/t/horizontal-scroll-on-the-layers-panel/643/54
// @author       aolko + https://forum.figma.com/u/Toni_Andric & https://forum.figma.com/u/Gomes_Ivan
// @match        http*://www.figma.com/file/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=figma.com
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Old way
    /*
    GM_addStyle(`
    [class*="object_row--indent--"] {
        margin: 0 !important;
        width: 8px;
    }
    `);
    */

    GM_addStyle(`
        [data-testid="layer-row-with-children"],
        [data-testid="layer-row"],
        [class|='scroll_container--innerScrollContainer']:not([class|='object_row--instance--']) {
            /* Make each row take up as much horizontal space as it can. */
            width: 100% !important;
        }
        [class|=pages_panel--objectPanelContent-] {
            /* this is what enables scrolling (if needed) in both directions */
            overflow: auto;
        }
        [class*=js-fullscreen-wheel-event-capture][class*=objects_panel--scrollContainer][class*=objects_panel--scrollContainerWithBorder][class*=scroll_container--clipContainer] {
            /* This overrides the inline styles that get added on sidebar resizing. */
            width: 1000px !important;
            position: relative;
        }
        [class|=object_row--indent-]:not([class|=object_row--indent-]:first-of-type) {
            /* This reduces the indentation of nested layers */
            width: 5px;
        }
    `);
    // Additionally, fix the Layers panel label. Prevent overlaying the main area in certain edge cases
    var header = document.querySelector("[class|=pages_panel--objectPanelContent-] [style*='translate3d(0px, 0px, 0px)']");
    header.style.position = 'absolute';
    header.style.transform = 'translate3d(0px, 0px, 0px);';
})();