« get me outta code hell

scratchblocks-generator-3 - scratchblocks generator for projects made in 3.0
about summary refs log tree commit diff
path: root/src/js/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/main.js')
-rw-r--r--src/js/main.js8
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});
     }
 }