MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / setHScrollValue

Function setHScrollValue

src/lib/editorManager.js:2572–2587  ·  view source on GitHub ↗

* Sets scrollbars value based on the editor's scroll position.

()

Source from the content-addressed store, hash-verified

2570 * Sets scrollbars value based on the editor's scroll position.
2571 */
2572 function setHScrollValue() {
2573 if (appSettings.value.textWrap || preventScrollbarH) return;
2574 const scroller = editor?.scrollDOM;
2575 if (!scroller) return;
2576 const maxScroll = Math.max(scroller.scrollWidth - scroller.clientWidth, 0);
2577 if (maxScroll <= 0) {
2578 lastScrollLeft = 0;
2579 $hScrollbar.value = 0;
2580 return;
2581 }
2582 const scrollLeft = scroller.scrollLeft;
2583 if (scrollLeft === lastScrollLeft) return;
2584 lastScrollLeft = scrollLeft;
2585 const factor = scrollLeft / maxScroll;
2586 $hScrollbar.value = clamp01(factor);
2587 }
2588
2589 /**
2590 * Handles the scroll left event.

Callers 3

onscrollHEndFunction · 0.85
onscrollleftFunction · 0.85
switchFileFunction · 0.85

Calls 1

clamp01Function · 0.85

Tested by

no test coverage detected