Tweak history handling in demo

This commit is contained in:
Dan Holmsand 2016-05-02 12:44:02 +02:00
parent 86b98dcdba
commit fe749392d7
1 changed files with 5 additions and 3 deletions

View File

@ -43,8 +43,9 @@
:goto-page (let [path x
_ (assert (string? path))]
(when-some [h history]
(r/after-render (fn []
(.setToken h x)
(r/after-render #(set! js/document.body.scrollTop 0))
(js/scrollTo 0 0)))
state)
(recur state [:set-page x]))))
@ -76,7 +77,8 @@
(string/replace #"/*$" ""))))
(History.)))
(evt/listen EventType.NAVIGATE #(when (.-isNavigation %)
(emit [:set-page (.-token %)])))
(emit [:set-page (.-token %)])
(r/flush)))
(.setEnabled true))
(let [token (.getToken history)
p (if (and page (not html5) (empty? token))