Sha256: 12f03b4c9e6830c536fa56b5cd33f48cd703733c2a06405e0025d127686b3460

Contents?: true

Size: 859 Bytes

Versions: 9

Compression:

Stored size: 859 Bytes

Contents

/// Wrap elements that can be too wide in scrollable containers

const SCROLLABLE_CONTAINER_CLSS = "scrollable-container";

function makeScrollable() {
    // Make tables scrollable
    let elems = document.querySelectorAll("main > table");

    for (const elem of elems) {
        let container = document.createElement("div");
        elem.parentElement.insertBefore(container, elem);
        elem.remove();

        container.classList.add(SCROLLABLE_CONTAINER_CLSS);
        container.appendChild(elem);
    }

    // Make display math scrollable
    elems = document.querySelectorAll("main > span > .katex-display");
    for (const elem of elems) {
        let container = elem.parentElement;

        if (container.children.length == 1) {
            container.classList.add(SCROLLABLE_CONTAINER_CLSS);
        }
    }
}

export default makeScrollable;

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hematite-0.1.18 assets/js/scrollables.mjs
hematite-0.1.17 assets/js/scrollables.mjs
hematite-0.1.16 assets/js/scrollables.mjs
hematite-0.1.15 assets/js/scrollables.mjs
hematite-0.1.14 assets/js/scrollables.mjs
hematite-0.1.13 assets/js/scrollables.mjs
hematite-0.1.12 assets/js/scrollables.mjs
hematite-0.1.11 assets/js/scrollables.mjs
hematite-0.1.10 assets/js/scrollables.mjs