about summary refs log tree commit diff
path: root/app/javascript/packs/public.js
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-01-11 10:53:58 +0100
committerGitHub <noreply@github.com>2019-01-11 10:53:58 +0100
commit2cfa55185a5fc7d93a160a4e9a4730aae6725b0f (patch)
treec57169b5a3d717f4e68b8ec5d2d6e220d1456434 /app/javascript/packs/public.js
parentd1da0a1086fa25f22739277fbf32ba1b3745317d (diff)
parent394525e32994e605093c87d3a9fad2a4202f3401 (diff)
Merge pull request #885 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/javascript/packs/public.js')
-rw-r--r--app/javascript/packs/public.js28
1 files changed, 18 insertions, 10 deletions
diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js
index 47c4bf75c..196d2d02f 100644
--- a/app/javascript/packs/public.js
+++ b/app/javascript/packs/public.js
@@ -16,6 +16,17 @@ function main() {
   const Rellax = require('rellax');
   const createHistory = require('history').createBrowserHistory;
 
+  const scrollToDetailedStatus = () => {
+    const history = createHistory();
+    const detailedStatuses = document.querySelectorAll('.public-layout .detailed-status');
+    const location = history.location;
+
+    if (detailedStatuses.length === 1 && (!location.state || !location.state.scrolledToDetailedStatus)) {
+      detailedStatuses[0].scrollIntoView();
+      history.replace(location.pathname, { ...location.state, scrolledToDetailedStatus: true });
+    }
+  };
+
   ready(() => {
     const locale = document.documentElement.lang;
 
@@ -59,8 +70,14 @@ function main() {
 
           ReactDOM.render(<MediaContainer locale={locale} components={reactComponents} />, content);
           document.body.appendChild(content);
+          scrollToDetailedStatus();
         })
-        .catch(error => console.error(error));
+        .catch(error => {
+          console.error(error);
+          scrollToDetailedStatus();
+        });
+    } else {
+      scrollToDetailedStatus();
     }
 
     const parallaxComponents = document.querySelectorAll('.parallax');
@@ -68,15 +85,6 @@ function main() {
     if (parallaxComponents.length > 0 ) {
       new Rellax('.parallax', { speed: -1 });
     }
-
-    const history = createHistory();
-    const detailedStatuses = document.querySelectorAll('.public-layout .detailed-status');
-    const location = history.location;
-
-    if (detailedStatuses.length === 1 && (!location.state || !location.state.scrolledToDetailedStatus)) {
-      detailedStatuses[0].scrollIntoView();
-      history.replace(location.pathname, { ...location.state, scrolledToDetailedStatus: true });
-    }
   });
 }