Browse code

Add add an event+effect for scrolling the window to the bottom

Joseph Weston authored on 06/12/2021 03:25:26
Showing 1 changed files
... ...
@@ -30,6 +30,18 @@
30 30
    (contains? equipment cmd) (equipment cmd)
31 31
    :else {:err (str "Unknown command '" cmdline "'")})))
32 32
 
33
+(re-frame/reg-fx
34
+ :window/scroll-smoothly-to-bottom
35
+ (fn []
36
+   (let [x (.-scrollX js/window)
37
+         y (.-scrollMaxY js/window)]
38
+     (.scrollTo js/window (clj->js {:left x :top y :behavior :smooth})))))
39
+
40
+(re-frame/reg-event-fx
41
+ ::scroll-to-bottom
42
+ (fn []
43
+   {:window/scroll-smoothly-to-bottom []}))
44
+
33 45
 (re-frame/reg-event-fx
34 46
  ::submit-cmd
35 47
  (fn [cofx _]