mirror of https://github.com/status-im/reagent.git
Handle page switching better on ios
This commit is contained in:
parent
b0a35f3e4e
commit
d1d5d3c31e
|
@ -21,19 +21,21 @@
|
||||||
(.setUseFragment false)))
|
(.setUseFragment false)))
|
||||||
(History.)))))
|
(History.)))))
|
||||||
|
|
||||||
|
(def history (create-history))
|
||||||
|
|
||||||
(defn setup-history []
|
(defn setup-history []
|
||||||
(when-let [h (create-history)]
|
(when-let [h history]
|
||||||
(events/listen h hevt/NAVIGATE
|
(events/listen h hevt/NAVIGATE
|
||||||
(fn [e]
|
(fn [e]
|
||||||
(reset! page (subs (.-token e)
|
(reset! page (subs (.-token e)
|
||||||
(count @base-path)))
|
(count @base-path)))
|
||||||
(reagent/flush)))
|
(reagent/flush)))
|
||||||
(add-watch page ::history (fn [_ _ oldp newp]
|
(add-watch page ::history (fn [_ _ oldp newp]
|
||||||
(.setToken h (str @base-path newp))))
|
(when-not (= oldp newp)
|
||||||
(.setEnabled h true)
|
(.setToken h (str @base-path newp)))))
|
||||||
h))
|
(.setEnabled h true)))
|
||||||
|
|
||||||
(def history (setup-history))
|
(js/setTimeout setup-history 100)
|
||||||
|
|
||||||
(defn set-start-page [p]
|
(defn set-start-page [p]
|
||||||
(when html5-history
|
(when html5-history
|
||||||
|
@ -74,9 +76,8 @@
|
||||||
(fn [e]
|
(fn [e]
|
||||||
(.preventDefault e)
|
(.preventDefault e)
|
||||||
(reset! page href)
|
(reset! page href)
|
||||||
(reagent/flush)
|
(reagent/next-tick
|
||||||
(set! (.-scrollTop (.-body js/document))
|
#(set! (.-scrollTop (.-body js/document)) 0)))
|
||||||
0))
|
|
||||||
identity))
|
identity))
|
||||||
child]))
|
child]))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue