don't rerender before load (#541)

This commit is contained in:
Yoshua Wuyts [taking a vacation, back 31/07]
2017-08-01 02:08:12 +02:00
committed by GitHub
parent 30fcdf9bf6
commit 681bb4a39a
+6 -2
View File
@@ -39,6 +39,7 @@ function Choo (opts) {
this._hrefEnabled = opts.href === undefined ? true : opts.href this._hrefEnabled = opts.href === undefined ? true : opts.href
this._hasWindow = typeof window !== 'undefined' this._hasWindow = typeof window !== 'undefined'
this._createLocation = nanolocation this._createLocation = nanolocation
this._loaded = false
this._tree = null this._tree = null
// properties that are part of the API // properties that are part of the API
@@ -87,9 +88,11 @@ Choo.prototype.start = function () {
var self = this var self = this
if (this._historyEnabled) { if (this._historyEnabled) {
this.emitter.prependListener(this._events.NAVIGATE, function () { this.emitter.prependListener(this._events.NAVIGATE, function () {
self.emitter.emit(self._events.RENDER)
self.state.query = nanoquery(window.location.search) self.state.query = nanoquery(window.location.search)
setTimeout(scrollToAnchor.bind(null, window.location.hash), 0) if (self._loaded) {
self.emitter.emit(self._events.RENDER)
setTimeout(scrollToAnchor.bind(null, window.location.hash), 0)
}
}) })
this.emitter.prependListener(this._events.POPSTATE, function () { this.emitter.prependListener(this._events.POPSTATE, function () {
@@ -147,6 +150,7 @@ Choo.prototype.start = function () {
documentReady(function () { documentReady(function () {
self.emitter.emit(self._events.DOMCONTENTLOADED) self.emitter.emit(self._events.DOMCONTENTLOADED)
self._loaded = true
}) })
return this._tree return this._tree