diff options
author | Florrie <towerofnix@gmail.com> | 2019-12-20 18:01:00 -0400 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2019-12-20 18:01:00 -0400 |
commit | 35f1231edf8ac26398798b8857f95e2aac7819fa (patch) | |
tree | 81034f49fbbc5d7b0082bf6db749b0922acf9ce1 /src | |
parent | 763b8f5777c1ff23114057c40d8b746ef73f21d9 (diff) |
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).
Diffstat (limited to 'src')
-rw-r--r-- | src/js/main.js | 8 |
1 files 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}); } } |