mirror of
https://github.com/penpot/penpot.git
synced 2025-06-07 14:41:38 +02:00
🐛 Fix go to page interaction in viewer
This commit is contained in:
parent
917ab4acc9
commit
0d94941001
4 changed files with 20 additions and 7 deletions
|
@ -77,12 +77,24 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [token (get-in state [:route :params :token])]
|
(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
|
(defn select-page
|
||||||
[index]
|
[index]
|
||||||
(SelectPage. 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
|
;; --- Toggle Flag
|
||||||
|
|
||||||
(defrecord ToggleFlag [key]
|
(defrecord ToggleFlag [key]
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
{:mixins [mx/static mx/reactive]
|
{:mixins [mx/static mx/reactive]
|
||||||
:will-mount viewer-page-will-mount
|
:will-mount viewer-page-will-mount
|
||||||
:did-remount viewer-page-did-remount}
|
:did-remount viewer-page-did-remount}
|
||||||
[token index]
|
[token index id]
|
||||||
(let [flags (mx/react flags-ref)
|
(let [flags (mx/react flags-ref)
|
||||||
sitemap? (contains? flags :sitemap)
|
sitemap? (contains? flags :sitemap)
|
||||||
get-order #(get-in % [:metadata :order])
|
get-order #(get-in % [:metadata :order])
|
||||||
|
@ -55,4 +55,6 @@
|
||||||
(when sitemap?
|
(when sitemap?
|
||||||
(sitemap pages index))
|
(sitemap pages index))
|
||||||
(nav flags)
|
(nav flags)
|
||||||
(canvas (nth pages index))]))
|
(canvas (if (= id nil)
|
||||||
|
(nth pages index)
|
||||||
|
(some #(= id (:id %)) pages)))]))
|
||||||
|
|
|
@ -81,7 +81,6 @@
|
||||||
:strokeOpacity "1"
|
:strokeOpacity "1"
|
||||||
:easing (translate-ease easing)
|
:easing (translate-ease easing)
|
||||||
:delay delay
|
:delay delay
|
||||||
:class "itx-displayed"
|
|
||||||
:duration duration}))))
|
:duration duration}))))
|
||||||
|
|
||||||
(defn- run-hide-interaction
|
(defn- run-hide-interaction
|
||||||
|
@ -94,14 +93,13 @@
|
||||||
:strokeOpacity "0"
|
:strokeOpacity "0"
|
||||||
:easing (translate-ease easing)
|
:easing (translate-ease easing)
|
||||||
:delay delay
|
:delay delay
|
||||||
:class "itx-hidden"
|
|
||||||
:duration duration}))))
|
:duration duration}))))
|
||||||
|
|
||||||
(defn- run-toggle-interaction
|
(defn- run-toggle-interaction
|
||||||
[{:keys [element easing delay duration
|
[{:keys [element easing delay duration
|
||||||
animation direction] :as itx}]
|
animation direction] :as itx}]
|
||||||
(let [dom (dom/get-element (str "shape-" element))]
|
(let [dom (dom/get-element (str "shape-" element))]
|
||||||
(if (= (:class dom) "itx-hidden")
|
(if (= direction :reverse)
|
||||||
(run-show-interaction itx)
|
(run-show-interaction itx)
|
||||||
(run-hide-interaction itx))))
|
(run-hide-interaction itx))))
|
||||||
|
|
||||||
|
@ -173,7 +171,7 @@
|
||||||
|
|
||||||
(defn- run-gotopage-interaction
|
(defn- run-gotopage-interaction
|
||||||
[{:keys [page]}]
|
[{:keys [page]}]
|
||||||
(st/emit! (dv/select-page page)))
|
(st/emit! (dv/go-to-page page)))
|
||||||
|
|
||||||
(defn- run-color-interaction
|
(defn- run-color-interaction
|
||||||
[{:keys [element fill-color stroke-color direction easing delay duration]}]
|
[{:keys [element fill-color stroke-color direction easing delay duration]}]
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
:let [selected? (= i selected)]]
|
:let [selected? (= i selected)]]
|
||||||
[:li {:class (when selected? "selected")
|
[:li {:class (when selected? "selected")
|
||||||
:on-click (partial on-click i)
|
:on-click (partial on-click i)
|
||||||
|
:id (str "page-" (:id page))
|
||||||
:key (str i)}
|
:key (str i)}
|
||||||
[:div.page-icon i/page]
|
[:div.page-icon i/page]
|
||||||
[:span (:name page)]])]]))
|
[:span (:name page)]])]]))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue