From 04a411afd200bba3b228f9619f4ebdfa35a62481 Mon Sep 17 00:00:00 2001 From: Rik Smith-Unna Date: Thu, 29 Jun 2017 02:46:53 +0300 Subject: [PATCH] Do not navigate until DOMContentLoaded --- app/client/models/main.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/client/models/main.js b/app/client/models/main.js index ec260e9..05b3fe1 100644 --- a/app/client/models/main.js +++ b/app/client/models/main.js @@ -3,9 +3,22 @@ const C = require('../lib/constants') module.exports = (state, bus) => { state.initialising = false - bus.on('initialising:start', () => { + let domloaded = false + let initstarted = true + + const start = () => { state.initialising = true bus.emit('pushState', '#initial') + } + + bus.on('initialising:start', () => { + initstarted = true + if (domloaded) return start() + }) + + bus.on('DOMContentLoaded', () => { + domloaded = true + if (initstarted) return start() }) bus.on('initialising:stop', () => {