fix: preserve the scroll position when navigating pages

pull/5465/head
Tienson Qin 2022-05-28 02:12:42 +08:00
parent 062c2523bc
commit e649650d28
2 changed files with 5 additions and 4 deletions

View File

@ -148,6 +148,7 @@
(when @*scroll-timer
(js/clearTimeout @*scroll-timer))
(state/set-state! :ui/scrolling? true)
(state/save-scroll-position! (util/scroll-top))
(reset! *scroll-timer (js/setTimeout
(fn [] (state/set-state! :ui/scrolling? false)) 500)))
false)))

View File

@ -16,7 +16,6 @@
[{:keys [to path-params query-params push]
:or {push true}}]
(let [route-fn (if push rfe/push-state rfe/replace-state)]
(state/save-scroll-position! (util/scroll-top))
(route-fn to path-params query-params))
;; force return nil for usage in render phase of React
nil)
@ -126,9 +125,10 @@
(update-page-label! route)
(if-let [anchor (get-in route [:query-params :anchor])]
(jump-to-anchor! anchor)
(util/scroll-to (util/app-scroll-container-node)
(js/setTimeout #(util/scroll-to (util/app-scroll-container-node)
(state/get-saved-scroll-position)
false))))
true)
100))))
(defn go-to-search!
[search-mode]