From 0d94941001e8232732bc57f0fb2368203c56fb0c Mon Sep 17 00:00:00 2001 From: "mathieu.brunot" Date: Fri, 22 Feb 2019 03:43:55 +0100 Subject: [PATCH] :bug: Fix go to page interaction in viewer --- frontend/src/uxbox/view/data/viewer.cljs | 14 +++++++++++++- frontend/src/uxbox/view/ui/viewer.cljs | 6 ++++-- .../src/uxbox/view/ui/viewer/interactions.cljs | 6 ++---- frontend/src/uxbox/view/ui/viewer/sitemap.cljs | 1 + 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/frontend/src/uxbox/view/data/viewer.cljs b/frontend/src/uxbox/view/data/viewer.cljs index 6007b93730..68679832e6 100644 --- a/frontend/src/uxbox/view/data/viewer.cljs +++ b/frontend/src/uxbox/view/data/viewer.cljs @@ -77,12 +77,24 @@ ptk/WatchEvent (watch [_ state stream] (let [token (get-in state [:route :params :token])] - (rx/of (rt/navigate :view/viewer {:token token :index index}))))) + (rx/of (rt/navigate :view/viewer {:token token :index index :id nil}))))) (defn select-page [index] (SelectPage. index)) +;; --- Go to Page + +(defrecord GoToPage [id] + ptk/WatchEvent + (watch [_ state stream] + (let [token (get-in state [:route :params :token])] + (rx/of (rt/navigate :view/viewer {:token token :index nil :id id}))))) + +(defn go-to-page + [id] + (GoToPage id)) + ;; --- Toggle Flag (defrecord ToggleFlag [key] diff --git a/frontend/src/uxbox/view/ui/viewer.cljs b/frontend/src/uxbox/view/ui/viewer.cljs index 12cbac08a3..3b40150ec1 100644 --- a/frontend/src/uxbox/view/ui/viewer.cljs +++ b/frontend/src/uxbox/view/ui/viewer.cljs @@ -46,7 +46,7 @@ {:mixins [mx/static mx/reactive] :will-mount viewer-page-will-mount :did-remount viewer-page-did-remount} - [token index] + [token index id] (let [flags (mx/react flags-ref) sitemap? (contains? flags :sitemap) get-order #(get-in % [:metadata :order]) @@ -55,4 +55,6 @@ (when sitemap? (sitemap pages index)) (nav flags) - (canvas (nth pages index))])) + (canvas (if (= id nil) + (nth pages index) + (some #(= id (:id %)) pages)))])) diff --git a/frontend/src/uxbox/view/ui/viewer/interactions.cljs b/frontend/src/uxbox/view/ui/viewer/interactions.cljs index f07617a928..112756cc8a 100644 --- a/frontend/src/uxbox/view/ui/viewer/interactions.cljs +++ b/frontend/src/uxbox/view/ui/viewer/interactions.cljs @@ -81,7 +81,6 @@ :strokeOpacity "1" :easing (translate-ease easing) :delay delay - :class "itx-displayed" :duration duration})))) (defn- run-hide-interaction @@ -94,14 +93,13 @@ :strokeOpacity "0" :easing (translate-ease easing) :delay delay - :class "itx-hidden" :duration duration})))) (defn- run-toggle-interaction [{:keys [element easing delay duration animation direction] :as itx}] (let [dom (dom/get-element (str "shape-" element))] - (if (= (:class dom) "itx-hidden") + (if (= direction :reverse) (run-show-interaction itx) (run-hide-interaction itx)))) @@ -173,7 +171,7 @@ (defn- run-gotopage-interaction [{:keys [page]}] - (st/emit! (dv/select-page page))) + (st/emit! (dv/go-to-page page))) (defn- run-color-interaction [{:keys [element fill-color stroke-color direction easing delay duration]}] diff --git a/frontend/src/uxbox/view/ui/viewer/sitemap.cljs b/frontend/src/uxbox/view/ui/viewer/sitemap.cljs index 6155bed81c..b9ed9ff862 100644 --- a/frontend/src/uxbox/view/ui/viewer/sitemap.cljs +++ b/frontend/src/uxbox/view/ui/viewer/sitemap.cljs @@ -36,6 +36,7 @@ :let [selected? (= i selected)]] [:li {:class (when selected? "selected") :on-click (partial on-click i) + :id (str "page-" (:id page)) :key (str i)} [:div.page-icon i/page] [:span (:name page)]])]]))