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

Function updateScrollbarsFromMetrics

src/lib/editorManager.js:2624–2664  ·  view source on GitHub ↗
(metrics)

Source from the content-addressed store, hash-verified

2622 }
2623
2624 function updateScrollbarsFromMetrics(metrics) {
2625 if (!metrics) return;
2626
2627 const maxScrollTop = Math.max(
2628 metrics.scrollHeight - metrics.clientHeight,
2629 0,
2630 );
2631 if (maxScrollTop <= 0) {
2632 $vScrollbar.hide();
2633 lastScrollTop = 0;
2634 $vScrollbar.value = 0;
2635 } else {
2636 if (!preventScrollbarV && metrics.scrollTop !== lastScrollTop) {
2637 lastScrollTop = metrics.scrollTop;
2638 $vScrollbar.value = clamp01(metrics.scrollTop / maxScrollTop);
2639 }
2640 $vScrollbar.render();
2641 }
2642
2643 if (appSettings.value.textWrap) {
2644 $hScrollbar.hide();
2645 return;
2646 }
2647
2648 const maxScrollLeft = Math.max(
2649 metrics.scrollWidth - metrics.clientWidth,
2650 0,
2651 );
2652 if (maxScrollLeft <= 0) {
2653 $hScrollbar.hide();
2654 lastScrollLeft = 0;
2655 $hScrollbar.value = 0;
2656 return;
2657 }
2658
2659 if (!preventScrollbarH && metrics.scrollLeft !== lastScrollLeft) {
2660 lastScrollLeft = metrics.scrollLeft;
2661 $hScrollbar.value = clamp01(metrics.scrollLeft / maxScrollLeft);
2662 }
2663 $hScrollbar.render();
2664 }
2665
2666 /**
2667 * Sets scrollbars value based on the editor's scroll position.

Callers

nothing calls this directly

Calls 3

clamp01Function · 0.85
hideMethod · 0.45
renderMethod · 0.45

Tested by

no test coverage detected