From 89292492dba2f10e4566c694de38c5cc7c3139bc Mon Sep 17 00:00:00 2001 From: Ruben Carlo Benante Date: Wed, 8 Jul 2026 09:48:49 -0300 Subject: [PATCH] empty track (no knob) when board fits, add fit tolerance (v1.5.1) --- Asset/js/top-scrollbar.js | 26 +++++++++++++++++++++----- Plugin.php | 2 +- VERSION | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Asset/js/top-scrollbar.js b/Asset/js/top-scrollbar.js index 5a1dbbd..49997a7 100644 --- a/Asset/js/top-scrollbar.js +++ b/Asset/js/top-scrollbar.js @@ -26,6 +26,10 @@ // Keep the thumb wide enough to grab, even on a very wide board. var MIN_THUMB = 24; + // Ignore a few px of residual overflow (padding / sub-pixel rounding) so a board that visually + // fits is treated as "no horizontal scroll" instead of showing an immovable near-full thumb. + var FIT_TOLERANCE = 4; + function getContainer() { return document.getElementById("board-container"); } @@ -74,17 +78,29 @@ thumb.style.transform = "translateX(" + Math.round(left) + "px)"; } - // Recompute thumb width/position; hide the whole bar when nothing to scroll. + // The board needs scrolling only if its content exceeds the viewport by more than the + // tolerance (absorbs a residual px or two so a fitting board reads as "no scroll"). + function needsScroll(m) { + return m && m.content - m.viewport > FIT_TOLERANCE; + } + + // Recompute the thumb. The (light) track stays visible for a STABLE height; when the board + // fits, just drop the knob (thumb width 0) so it reads as "nothing to scroll" without the + // layout jump that hiding the whole bar would cause. function layout() { var m = metrics(); - if (!m || m.content <= m.viewport || m.trackW <= 0) { - track.style.display = "none"; + if (!m || m.trackW <= 0) { return; } track.style.display = ""; + if (!needsScroll(m)) { + thumb.style.width = "0px"; + return; + } + var thumbW = Math.round(m.trackW * m.viewport / m.content); if (thumbW < MIN_THUMB) { thumbW = MIN_THUMB; } if (thumbW > m.trackW) { thumbW = m.trackW; } @@ -107,7 +123,7 @@ if (dragging) { return; } if (e.target !== getContainer()) { return; } var m = metrics(); - if (!m || m.content <= m.viewport) { return; } + if (!needsScroll(m)) { return; } positionThumb(m, thumb.offsetWidth); }, true); @@ -153,7 +169,7 @@ track.addEventListener("pointerdown", function (e) { if (e.target === thumb || dragging) { return; } var m = metrics(); - if (!m || m.content <= m.viewport) { return; } + if (!needsScroll(m)) { return; } var thumbW = thumb.offsetWidth; var maxThumb = m.trackW - thumbW; diff --git a/Plugin.php b/Plugin.php index fdf7059..2f9745d 100644 --- a/Plugin.php +++ b/Plugin.php @@ -51,7 +51,7 @@ class Plugin extends Base public function getPluginVersion() { - return '1.5.0'; + return '1.5.1'; } public function getPluginHomepage() diff --git a/VERSION b/VERSION index 3c7b7cc..7892381 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -ShrinkVertically v1.5 +ShrinkVertically v1.5.1