mirror of
https://github.com/penpot/penpot.git
synced 2025-05-24 00:36:10 +02:00
Fix interactions issues.
This commit is contained in:
parent
20e7afeee5
commit
80ebc17a26
7 changed files with 36 additions and 31 deletions
|
@ -43,7 +43,9 @@
|
||||||
xfmt (-> (gmt/matrix)
|
xfmt (-> (gmt/matrix)
|
||||||
(gmt/rotate* rotation center))
|
(gmt/rotate* rotation center))
|
||||||
|
|
||||||
props {:id (str id) :transform (str xfmt)}
|
props {:id (str "shape-" id)
|
||||||
|
:transform (str xfmt)}
|
||||||
|
|
||||||
attrs (merge props
|
attrs (merge props
|
||||||
(attrs/extract-style-attrs shape)
|
(attrs/extract-style-attrs shape)
|
||||||
(select-keys shape [:cx :cy :rx :ry]))]
|
(select-keys shape [:cx :cy :rx :ry]))]
|
||||||
|
|
|
@ -69,7 +69,8 @@
|
||||||
(let [xfmt (cond-> (or tmp-resize-xform (gmt/matrix))
|
(let [xfmt (cond-> (or tmp-resize-xform (gmt/matrix))
|
||||||
tmp-displacement (gmt/translate tmp-displacement))
|
tmp-displacement (gmt/translate tmp-displacement))
|
||||||
|
|
||||||
attrs {:id (str id) :transform (str xfmt)}]
|
attrs {:id (str "shape-" id)
|
||||||
|
:transform (str xfmt)}]
|
||||||
[:g attrs
|
[:g attrs
|
||||||
(for [item (reverse items)
|
(for [item (reverse items)
|
||||||
:let [key (str item)]]
|
:let [key (str item)]]
|
||||||
|
|
|
@ -61,6 +61,6 @@
|
||||||
[{:keys [content id metadata] :as shape}]
|
[{:keys [content id metadata] :as shape}]
|
||||||
(let [view-box (apply str (interpose " " (:view-box metadata)))
|
(let [view-box (apply str (interpose " " (:view-box metadata)))
|
||||||
props {:view-box view-box
|
props {:view-box view-box
|
||||||
:id (str id)
|
:id (str "shape-" id)
|
||||||
:dangerouslySetInnerHTML {:__html content}}]
|
:dangerouslySetInnerHTML {:__html content}}]
|
||||||
[:svg props]))
|
[:svg props]))
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
tmp-displacement (gmt/translate tmp-displacement))
|
tmp-displacement (gmt/translate tmp-displacement))
|
||||||
|
|
||||||
props {:x x1 :y y1
|
props {:x x1 :y y1
|
||||||
:id (str id)
|
:id (str "shape-" id)
|
||||||
:preserve-aspect-ratio "none"
|
:preserve-aspect-ratio "none"
|
||||||
:xlink-href (:url image)
|
:xlink-href (:url image)
|
||||||
:transform (str xfmt)
|
:transform (str xfmt)
|
||||||
|
|
|
@ -51,7 +51,8 @@
|
||||||
xfmt (cond-> (gmt/matrix)
|
xfmt (cond-> (gmt/matrix)
|
||||||
(pos? rotation) (rotate shape))
|
(pos? rotation) (rotate shape))
|
||||||
|
|
||||||
props {:x x1 :y y1 :id id
|
props {:x x1 :y y1
|
||||||
|
:id (str "shape-" id)
|
||||||
:width width
|
:width width
|
||||||
:height height
|
:height height
|
||||||
:transform (str xfmt)}
|
:transform (str xfmt)}
|
||||||
|
|
|
@ -521,7 +521,7 @@
|
||||||
:gotourl (url-input form-ref)
|
:gotourl (url-input form-ref)
|
||||||
:gotopage (pages-input form-ref)
|
:gotopage (pages-input form-ref)
|
||||||
:color (color-input form-ref)
|
:color (color-input form-ref)
|
||||||
:rotate (rotate-input form-ref)
|
;; :rotate (rotate-input form-ref)
|
||||||
:size (resize-input form-ref)
|
:size (resize-input form-ref)
|
||||||
:moveto (moveto-input form-ref)
|
:moveto (moveto-input form-ref)
|
||||||
:moveby (moveby-input form-ref)
|
:moveby (moveby-input form-ref)
|
||||||
|
|
|
@ -116,15 +116,14 @@
|
||||||
[{:keys [x1 y1 rotation] :as shape}
|
[{:keys [x1 y1 rotation] :as shape}
|
||||||
{:keys [resize-width resize-height easing
|
{:keys [resize-width resize-height easing
|
||||||
element delay duration direction] :as opts}]
|
element delay duration direction] :as opts}]
|
||||||
#_(if (= direction :reverse)
|
(let [{:keys [width height]} (geom/size shape)
|
||||||
(let [end (geom/transformation-matrix shape)]
|
dom (dom/get-element (str "shape-" element))]
|
||||||
(animate :targets [(str "#shape-" element)]
|
(if (= direction :reverse)
|
||||||
:transform (str end)
|
(animate* dom {:easing (translate-ease easing)
|
||||||
:easing (translate-ease easing)
|
:delay delay
|
||||||
:delay delay
|
:duration duration
|
||||||
:duration duration
|
:width width
|
||||||
:loop false))
|
:height height})
|
||||||
(let [dom (dom/get-element (str "shape-" element))]
|
|
||||||
(animate* dom {:easing (translate-ease easing)
|
(animate* dom {:easing (translate-ease easing)
|
||||||
:delay delay
|
:delay delay
|
||||||
:duration duration
|
:duration duration
|
||||||
|
@ -163,21 +162,23 @@
|
||||||
:fill fill-color
|
:fill fill-color
|
||||||
:stroke stroke-color}))))
|
:stroke stroke-color}))))
|
||||||
|
|
||||||
(defn- run-rotate-interaction
|
;; (defn- run-rotate-interaction
|
||||||
[{:keys [element rotation direction easing delay duration] :as opts}]
|
;; [{:keys [element rotation direction easing delay duration] :as opts}]
|
||||||
#_(let [shape (get-in @st/state [:shapes element])
|
;; (let [shape (get-in @st/state [:shapes element])
|
||||||
dom (dom/get-element (str "shape-" element))
|
;; {:keys [x1 y1 width height]} (geom/size shape)
|
||||||
mtx1 (geom/transformation-matrix (update shape :rotation + rotation))
|
;;
|
||||||
mtx2 (geom/transformation-matrix shape)]
|
;; dom (dom/get-element (str "shape-" element))
|
||||||
(if (= direction :reverse)
|
;; mtx1 (geom/transformation-matrix (update shape :rotation + rotation))
|
||||||
(animate* dom {:easing (translate-ease easing)
|
;; mtx2 (geom/transformation-matrix shape)]
|
||||||
:delay delay
|
;; (if (= direction :reverse)
|
||||||
:duration duration
|
;; (animate* dom {:easing (translate-ease easing)
|
||||||
:transform (str mtx2)})
|
;; :delay delay
|
||||||
(animate* dom {:easing (translate-ease easing)
|
;; :duration duration
|
||||||
:delay delay
|
;; :transform (str mtx2)})
|
||||||
:duration duration
|
;; (animate* dom {:easing (translate-ease easing)
|
||||||
:transform (str mtx1)}))))
|
;; :delay delay
|
||||||
|
;; :duration duration
|
||||||
|
;; :transform (str mtx1)}))))
|
||||||
|
|
||||||
(defn- run-interaction
|
(defn- run-interaction
|
||||||
"Given an interaction data structure return
|
"Given an interaction data structure return
|
||||||
|
@ -190,7 +191,7 @@
|
||||||
:size (run-size-interaction itx)
|
:size (run-size-interaction itx)
|
||||||
:opacity (run-opacity-interaction itx)
|
:opacity (run-opacity-interaction itx)
|
||||||
:color (run-color-interaction itx)
|
:color (run-color-interaction itx)
|
||||||
:rotate (run-rotate-interaction itx)
|
;; :rotate (run-rotate-interaction itx)
|
||||||
:gotourl (run-gotourl-interaction itx)
|
:gotourl (run-gotourl-interaction itx)
|
||||||
:gotopage (run-gotopage-interaction itx)
|
:gotopage (run-gotopage-interaction itx)
|
||||||
(throw (ex-info "undefined interaction" {:action action}))))
|
(throw (ex-info "undefined interaction" {:action action}))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue