Spaces:
Sleeping
Sleeping
Download frontend/node_modules/@mui/utils/legacy/scrollLeft/scrollLeft.js from sepidnes/pythonic-rag-FastAPIReact: direct link, hf CLI and curl.
- Browser
- Download file 2.07 kB
-
https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/56fda741e84da791ee2e6198479f1d5630989f6c/frontend/node_modules/%40mui/utils/legacy/scrollLeft/scrollLeft.js
- Command line
-
hf download hf://spaces/sepidnes/pythonic-rag-FastAPIReact@56fda741e84da791ee2e6198479f1d5630989f6c/frontend/node_modules/@mui/utils/legacy/scrollLeft/scrollLeft.js
-
curl -L -o scrollLeft.js https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/56fda741e84da791ee2e6198479f1d5630989f6c/frontend/node_modules/%40mui/utils/legacy/scrollLeft/scrollLeft.js
2.07 kB
| // Source from https://github.com/alitaheri/normalize-scroll-left | |
| var cachedType; | |
| /** | |
| * Based on the jquery plugin https://github.com/othree/jquery.rtl-scroll-type | |
| * | |
| * Types of scrollLeft, assuming scrollWidth=100 and direction is rtl. | |
| * | |
| * Type | <- Most Left | Most Right -> | Initial | |
| * ---------------- | ------------ | ------------- | ------- | |
| * default | 0 | 100 | 100 | |
| * negative (spec*) | -100 | 0 | 0 | |
| * reverse | 100 | 0 | 0 | |
| * | |
| * Edge 85: default | |
| * Safari 14: negative | |
| * Chrome 85: negative | |
| * Firefox 81: negative | |
| * IE11: reverse | |
| * | |
| * spec* https://drafts.csswg.org/cssom-view/#dom-window-scroll | |
| */ | |
| export function detectScrollType() { | |
| if (cachedType) { | |
| return cachedType; | |
| } | |
| var dummy = document.createElement('div'); | |
| var container = document.createElement('div'); | |
| container.style.width = '10px'; | |
| container.style.height = '1px'; | |
| dummy.appendChild(container); | |
| dummy.dir = 'rtl'; | |
| dummy.style.fontSize = '14px'; | |
| dummy.style.width = '4px'; | |
| dummy.style.height = '1px'; | |
| dummy.style.position = 'absolute'; | |
| dummy.style.top = '-1000px'; | |
| dummy.style.overflow = 'scroll'; | |
| document.body.appendChild(dummy); | |
| cachedType = 'reverse'; | |
| if (dummy.scrollLeft > 0) { | |
| cachedType = 'default'; | |
| } else { | |
| dummy.scrollLeft = 1; | |
| if (dummy.scrollLeft === 0) { | |
| cachedType = 'negative'; | |
| } | |
| } | |
| document.body.removeChild(dummy); | |
| return cachedType; | |
| } | |
| // Based on https://stackoverflow.com/a/24394376 | |
| export function getNormalizedScrollLeft(element, direction) { | |
| var scrollLeft = element.scrollLeft; | |
| // Perform the calculations only when direction is rtl to avoid messing up the ltr behavior | |
| if (direction !== 'rtl') { | |
| return scrollLeft; | |
| } | |
| var type = detectScrollType(); | |
| switch (type) { | |
| case 'negative': | |
| return element.scrollWidth - element.clientWidth + scrollLeft; | |
| case 'reverse': | |
| return element.scrollWidth - element.clientWidth - scrollLeft; | |
| default: | |
| return scrollLeft; | |
| } | |
| } |