mirror of
https://github.com/penpot/penpot.git
synced 2025-05-23 20:56:12 +02:00
⚡ Skip calculate children modifiers on move
This commit is contained in:
parent
95a2da5ebc
commit
c9dadce12a
1 changed files with 39 additions and 34 deletions
|
@ -176,45 +176,50 @@
|
||||||
|
|
||||||
(defn calc-child-modifiers
|
(defn calc-child-modifiers
|
||||||
[parent child modifiers ignore-constraints transformed-parent-rect]
|
[parent child modifiers ignore-constraints transformed-parent-rect]
|
||||||
(let [constraints-h
|
|
||||||
(if-not ignore-constraints
|
|
||||||
(:constraints-h child (default-constraints-h child))
|
|
||||||
:scale)
|
|
||||||
|
|
||||||
constraints-v
|
(if (and (nil? (:resize-vector modifiers))
|
||||||
(if-not ignore-constraints
|
(nil? (:resize-vector-2 modifiers)))
|
||||||
(:constraints-v child (default-constraints-v child))
|
;; If we don't have a resize modifier we return the same modifiers
|
||||||
:scale)
|
modifiers
|
||||||
|
(let [constraints-h
|
||||||
|
(if-not ignore-constraints
|
||||||
|
(:constraints-h child (default-constraints-h child))
|
||||||
|
:scale)
|
||||||
|
|
||||||
modifiers-h (constraint-modifier (constraints-h const->type+axis) :x parent child modifiers transformed-parent-rect)
|
constraints-v
|
||||||
modifiers-v (constraint-modifier (constraints-v const->type+axis) :y parent child modifiers transformed-parent-rect)]
|
(if-not ignore-constraints
|
||||||
|
(:constraints-v child (default-constraints-v child))
|
||||||
|
:scale)
|
||||||
|
|
||||||
;; Build final child modifiers. Apply transform again to the result, to get the
|
modifiers-h (constraint-modifier (constraints-h const->type+axis) :x parent child modifiers transformed-parent-rect)
|
||||||
;; real modifiers that need to be applied to the child, including rotation as needed.
|
modifiers-v (constraint-modifier (constraints-v const->type+axis) :y parent child modifiers transformed-parent-rect)]
|
||||||
(cond-> {}
|
|
||||||
(or (contains? modifiers-h :displacement)
|
|
||||||
(contains? modifiers-v :displacement))
|
|
||||||
(assoc :displacement (cond-> (gpt/point (get-in modifiers-h [:displacement :x] 0)
|
|
||||||
(get-in modifiers-v [:displacement :y] 0))
|
|
||||||
(some? (:resize-transform modifiers))
|
|
||||||
(gpt/transform (:resize-transform modifiers))
|
|
||||||
|
|
||||||
:always
|
;; Build final child modifiers. Apply transform again to the result, to get the
|
||||||
(gmt/translate-matrix)))
|
;; real modifiers that need to be applied to the child, including rotation as needed.
|
||||||
|
(cond-> {}
|
||||||
|
(or (contains? modifiers-h :displacement)
|
||||||
|
(contains? modifiers-v :displacement))
|
||||||
|
(assoc :displacement (cond-> (gpt/point (get-in modifiers-h [:displacement :x] 0)
|
||||||
|
(get-in modifiers-v [:displacement :y] 0))
|
||||||
|
(some? (:resize-transform modifiers))
|
||||||
|
(gpt/transform (:resize-transform modifiers))
|
||||||
|
|
||||||
(:resize-vector modifiers-h)
|
:always
|
||||||
(assoc :resize-origin (:resize-origin modifiers-h)
|
(gmt/translate-matrix)))
|
||||||
:resize-vector (gpt/point (get-in modifiers-h [:resize-vector :x] 1)
|
|
||||||
(get-in modifiers-h [:resize-vector :y] 1)))
|
|
||||||
|
|
||||||
(:resize-vector modifiers-v)
|
(:resize-vector modifiers-h)
|
||||||
(assoc :resize-origin-2 (:resize-origin modifiers-v)
|
(assoc :resize-origin (:resize-origin modifiers-h)
|
||||||
:resize-vector-2 (gpt/point (get-in modifiers-v [:resize-vector :x] 1)
|
:resize-vector (gpt/point (get-in modifiers-h [:resize-vector :x] 1)
|
||||||
(get-in modifiers-v [:resize-vector :y] 1)))
|
(get-in modifiers-h [:resize-vector :y] 1)))
|
||||||
|
|
||||||
(:resize-transform modifiers)
|
(:resize-vector modifiers-v)
|
||||||
(assoc :resize-transform (:resize-transform modifiers)
|
(assoc :resize-origin-2 (:resize-origin modifiers-v)
|
||||||
:resize-transform-inverse (:resize-transform-inverse modifiers))
|
:resize-vector-2 (gpt/point (get-in modifiers-v [:resize-vector :x] 1)
|
||||||
|
(get-in modifiers-v [:resize-vector :y] 1)))
|
||||||
|
|
||||||
:always
|
(:resize-transform modifiers)
|
||||||
(clean-modifiers))))
|
(assoc :resize-transform (:resize-transform modifiers)
|
||||||
|
:resize-transform-inverse (:resize-transform-inverse modifiers))
|
||||||
|
|
||||||
|
:always
|
||||||
|
(clean-modifiers)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue