diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-04-06 13:30:19 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-04-06 13:30:19 -0300 |
commit | 5ab7f1f5d2f8c7f90f60be0dcdd0bcfbc14f4c5b (patch) | |
tree | dc8d0ab8031f847a0888826af76a1c201a1d0337 /src | |
parent | ae14f6844b66a46d153c69ca05538d144e8a4509 (diff) |
client: additional-names-box: smarter worthScrolling logic
https://discord.com/channels/749042497610842152/854020929113423924/1358446868811485426 Not too smart for our own good, though. https://discord.com/channels/749042497610842152/854020929113423924/1358454755566944286
Diffstat (limited to 'src')
-rw-r--r-- | src/static/js/client/additional-names-box.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/static/js/client/additional-names-box.js b/src/static/js/client/additional-names-box.js index 38e6d52f..7c1baef6 100644 --- a/src/static/js/client/additional-names-box.js +++ b/src/static/js/client/additional-names-box.js @@ -102,7 +102,30 @@ function handleAdditionalNamesBoxLinkClicked(domEvent) { ? info.box.getBoundingClientRect() : info.mainContentContainer.getBoundingClientRect()); - if (top + 20 < margin || top > 0.4 * window.innerHeight) { + const {bottom, height} = + (state.visible + ? info.box.getBoundingClientRect() + : {bottom: null}); + + const boxFitsInFrame = + (height + ? height < window.innerHeight - margin - 60 + : null); + + const worthScrolling = + top + 20 < margin || + + (height && boxFitsInFrame + ? top > 0.7 * window.innerHeight + : height && !boxFitsInFrame + ? top > 0.4 * window.innerHeight + ? top > 0.5 * window.innerHeight) || + + (bottom && bottomFitsInFrame + ? bottom > window.innerHeight - 20 + : false); + + if (worthScrolling) { if (!state.visible) { toggleAdditionalNamesBox(); } |