From 6a0a71de5a92af3600803a5bb18e57f72203f46b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 9 Nov 2016 12:37:52 +0100 Subject: [PATCH] Fix animations for icons and images. --- src/uxbox/main/ui/shapes/icon.cljs | 2 +- src/uxbox/view/ui/viewer/interactions.cljs | 46 +--------------------- 2 files changed, 3 insertions(+), 45 deletions(-) diff --git a/src/uxbox/main/ui/shapes/icon.cljs b/src/uxbox/main/ui/shapes/icon.cljs index 79f9427602..64208eda70 100644 --- a/src/uxbox/main/ui/shapes/icon.cljs +++ b/src/uxbox/main/ui/shapes/icon.cljs @@ -29,7 +29,7 @@ (mx/defc icon-shape {:mixins [mx/static]} [{:keys [x1 y1 content id metadata] :as shape} factory] - (let [key (str "shape-icon-raw-" id) + (let [key (str "shape-" id) ;; rfm (geom/transformation-matrix shape) view-box (apply str (interpose " " (:view-box metadata))) size (geom/size shape) diff --git a/src/uxbox/view/ui/viewer/interactions.cljs b/src/uxbox/view/ui/viewer/interactions.cljs index 59e15dc8df..86e4cf2711 100644 --- a/src/uxbox/view/ui/viewer/interactions.cljs +++ b/src/uxbox/view/ui/viewer/interactions.cljs @@ -112,49 +112,6 @@ :delay delay :duration duration})))) -;; (defn- run-size-interaction -;; [{:keys [element resize-width resize-height -;; easing delay duration] :as opts}] -;; (let [shape (get-in @st/state [:shapes element]) -;; tf (geom/transformation-matrix -;; (geom/resize shape (gpt/point resize-width resize-height)))] -;; (animate :targets [(str "#shape-" element)] -;; :transform (str tf) -;; :easing (translate-ease easing) -;; :delay delay -;; :duration duration -;; :loop false))) - -(defn- run-size-interaction-icon - [{:keys [x1 y1 view-box rotation] :as shape} - {:keys [resize-width resize-height easing - element delay duration direction] :as opts}] - (if (= direction :reverse) - (let [end (geom/transformation-matrix shape)] - (animate :targets [(str "#shape-" element)] - :transform (str end) - :easing (translate-ease easing) - :delay delay - :duration duration - :loop false)) - (let [orig-width (nth view-box 2) - orig-height (nth view-box 3) - scale-x (/ resize-width orig-width) - scale-y (/ resize-height orig-height) - center-x (- resize-width (/ resize-width 2)) - center-y (- resize-height (/ resize-height 2)) - end (-> (gmt/matrix) - (gmt/translate x1 y1) - (gmt/translate center-x center-y) - (gmt/rotate rotation) - (gmt/translate (- center-x) (- center-y)) - (gmt/scale scale-x scale-y)) - dom (dom/get-element (str "shape-" element))] - (animate* dom {:transform (str end) - :easing (translate-ease easing) - :delay delay - :duration duration})))) - (defn- run-size-interaction-rect [{:keys [x1 y1 rotation] :as shape} {:keys [resize-width resize-height easing @@ -178,7 +135,8 @@ [{:keys [element] :as opts}] (let [shape (get-in @st/state [:shapes element])] (case (:type shape) - :icon (run-size-interaction-icon shape opts) + :icon (run-size-interaction-rect shape opts) + :image (run-size-interaction-rect shape opts) :rect (run-size-interaction-rect shape opts)))) (defn- run-gotourl-interaction