From dc73d12c26ceaf1bd28794fe9feba77845b35a6b Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Wed, 13 Mar 2019 13:25:57 +0100 Subject: [PATCH] Dynamically load animations. This makes sure that we don't have to serve the open animation when the bar is actually closed. --- src/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index ccbb3d7..99b0a6c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,12 +1,14 @@ import "./style.scss"; -import {startClosedAnimation} from "./closed"; -import {startOpenAnimation} from "./open"; window.addEventListener('load', function () { if (document.body.classList.contains('open')) { - startOpenAnimation(); + import("./open").then(function (module) { + module.startOpenAnimation(); + }); } else { - startClosedAnimation(); + import("./closed").then(function (module) { + module.startClosedAnimation(); + }); } doIfAuthorized(showToggleButton);