From 35f1231edf8ac26398798b8857f95e2aac7819fa Mon Sep 17 00:00:00 2001 From: Florrie Date: Fri, 20 Dec 2019 18:01:00 -0400 Subject: only scroll into view on autoload it behaves kind of weirdly when scrollIntoView'ing from a position that is not already at the top (i.e. the initial state) and doesn't really make sense to do anyway when clicking manually (except arguably when using tab to scroll the list, but that's a whole different shebang to tackle). --- src/js/main.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/main.js b/src/js/main.js index f7ad5f4..20a1852 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -131,7 +131,7 @@ let project; let selectedTarget; const sym = Symbol(); -function presentTarget(targetName) { +function presentTarget(targetName, {autoload = false} = {}) { if (!project) { return; } @@ -180,7 +180,9 @@ function presentTarget(targetName) { // will push it out of the way). to deal with this, we should wait until all images positioned // before this target's element have loaded (but we should also make sure to skip images that // have already loaded). - setTimeout(() => el.scrollIntoView(), 100); + if (autoload) { + setTimeout(() => el.scrollIntoView(), 100); + } clearChildren(scriptArea); if (target.scripts.length) { @@ -225,6 +227,6 @@ function presentProject(p) { if (location.hash.includes(':')) { const targetName = decodeURIComponent(location.hash.slice(location.hash.indexOf(':') + 1)); - presentTarget(targetName); + presentTarget(targetName, {autoload: true}); } } -- cgit 1.3.0-6-gf8a5