* Sets scrollbars value based on the editor's scroll position.
()
| 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. |
no test coverage detected