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