Browse Source

enhance(mobile): clicking journals scrolls to top

Tienson Qin 5 months ago
parent
commit
ecc182879a
1 changed files with 7 additions and 4 deletions
  1. 7 4
      src/main/mobile/components/ui_silk.cljs

+ 7 - 4
src/main/mobile/components/ui_silk.cljs

@@ -23,10 +23,13 @@
 (rum/defc app-silk-tabs []
 (rum/defc app-silk-tabs []
   (let [[current-tab set-tab!] (mobile-state/use-tab)]
   (let [[current-tab set-tab!] (mobile-state/use-tab)]
     [:div.app-silk-tabs
     [:div.app-silk-tabs
-     {:on-pointer-down #(some-> (.-target ^js %)
-                                ^js (.closest ".as-item")
-                                ^js (.-dataset)
-                                ^js (.-tab) (set-tab!))}
+     {:on-pointer-down (fn [^js e]
+                         (when (= current-tab "home")
+                           (util/scroll-to-top false))
+                         (some-> (.-target e)
+                                 ^js (.closest ".as-item")
+                                 ^js (.-dataset)
+                                 ^js (.-tab) (set-tab!)))}
      [:span.as-item
      [:span.as-item
       {:class (when (= current-tab "home") "active")
       {:class (when (= current-tab "home") "active")
        :data-tab "home"}
        :data-tab "home"}