Skip to content

Commit

Permalink
Do not navigate until DOMContentLoaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Rik Smith-Unna committed Jun 28, 2017
1 parent 2d55457 commit 04a411a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/client/models/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 04a411a

Please sign in to comment.