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

Function setVScrollValue

src/lib/editorManager.js:2669–2687  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

2667 * Sets scrollbars value based on the editor's scroll position.
2668 */
2669 function setVScrollValue() {
2670 if (preventScrollbarV) return;
2671 const scroller = editor?.scrollDOM;
2672 if (!scroller) return;
2673 const maxScroll = Math.max(
2674 scroller.scrollHeight - scroller.clientHeight,
2675 0,
2676 );
2677 if (maxScroll <= 0) {
2678 lastScrollTop = 0;
2679 $vScrollbar.value = 0;
2680 return;
2681 }
2682 const scrollTop = scroller.scrollTop;
2683 if (scrollTop === lastScrollTop) return;
2684 lastScrollTop = scrollTop;
2685 const factor = scrollTop / maxScroll;
2686 $vScrollbar.value = clamp01(factor);
2687 }
2688
2689 /**
2690 * Handles the scroll top event.

Callers 3

onscrollVendFunction · 0.85
onscrolltopFunction · 0.85
switchFileFunction · 0.85

Calls 1

clamp01Function · 0.85

Tested by

no test coverage detected