From 7de7af4e41fd57b514485efeb804d9efcaaa2cd6 Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Fri, 19 Apr 2024 15:48:51 +0200 Subject: feat: add scroll-into-view effects --- src/frontend/tubo/events.cljs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/frontend/tubo/events.cljs b/src/frontend/tubo/events.cljs index a48a001..a989dcc 100644 --- a/src/frontend/tubo/events.cljs +++ b/src/frontend/tubo/events.cljs @@ -67,6 +67,12 @@ (fn [active] (set! (.. js/document.body -style -overflow) (if active "hidden" "auto")))) +(rf/reg-fx + ::scroll-into-view! + (fn [element] + (when element + (.scrollIntoView element (js-obj "behavior" "smooth"))))) + (rf/reg-fx ::document-title! (fn [title] @@ -193,6 +199,11 @@ {:db (assoc db :show-media-queue (not (:show-media-queue db))) ::body-overflow! (not (:show-media-queue db))})) +(rf/reg-event-fx + ::scroll-into-view + (fn [{:keys [db]} [_ element]] + {::scroll-into-view! element})) + (rf/reg-event-fx ::change-volume-level [(rf/inject-cofx :store)] -- cgit v1.2.3