mirror of
https://github.com/penpot/penpot.git
synced 2026-09-07 04:29:31 +00:00
wip roto 2
This commit is contained in:
parent
de4c7762ad
commit
835ed342f8
@ -446,33 +446,38 @@
|
|||||||
(let [prev-shapes (mf/use-var nil)
|
(let [prev-shapes (mf/use-var nil)
|
||||||
prev-modifiers (mf/use-var nil)
|
prev-modifiers (mf/use-var nil)
|
||||||
prev-transforms (mf/use-var nil)
|
prev-transforms (mf/use-var nil)
|
||||||
unflag (mf/use-var false)
|
changed-modifiers (mf/use-var nil)
|
||||||
|
|
||||||
|
ignore?
|
||||||
|
(mf/use-memo
|
||||||
|
(mf/deps modifiers)
|
||||||
|
(fn []
|
||||||
|
(= modifiers @changed-modifiers)))
|
||||||
|
|
||||||
copies
|
copies
|
||||||
(mf/use-memo ; TODO: ojo estas deps hay que revisarlas
|
(mf/use-memo ; TODO: ojo estas deps hay que revisarlas
|
||||||
(mf/deps modifiers (and (d/not-empty? @prev-modifiers) (d/not-empty? modifiers)) @unflag)
|
(mf/deps modifiers (and (d/not-empty? @prev-modifiers)
|
||||||
|
(d/not-empty? modifiers)))
|
||||||
(fn []
|
(fn []
|
||||||
(when-not @unflag
|
(if ignore?
|
||||||
|
{}
|
||||||
(let [shapes (->> (keys modifiers)
|
(let [shapes (->> (keys modifiers)
|
||||||
(mapv (d/getf objects)))]
|
(mapv (d/getf objects)))]
|
||||||
(get-copies shapes objects modifiers)))))
|
(get-copies shapes objects modifiers)))))
|
||||||
|
|
||||||
modifiers
|
modifiers
|
||||||
(mf/use-memo
|
(mf/use-memo
|
||||||
(mf/deps objects modifiers copies @unflag)
|
(mf/deps objects modifiers copies)
|
||||||
(fn []
|
(fn []
|
||||||
(if @unflag
|
(if ignore?
|
||||||
(do
|
modifiers
|
||||||
(reset! unflag false)
|
|
||||||
modifiers)
|
|
||||||
(let [new-modifiers (add-copies-modifiers copies objects modifiers)]
|
(let [new-modifiers (add-copies-modifiers copies objects modifiers)]
|
||||||
(js/console.log "==================")
|
(js/console.log "==================")
|
||||||
(js/console.log "modifiers (antes)" (clj->js modifiers))
|
(js/console.log "modifiers (antes)" (clj->js modifiers))
|
||||||
(js/console.log "copies" (clj->js copies))
|
(js/console.log "copies" (clj->js copies))
|
||||||
(js/console.log "modifiers (después)" (clj->js new-modifiers))
|
(js/console.log "modifiers (después)" (clj->js new-modifiers))
|
||||||
(reset! unflag true)
|
(reset! changed-modifiers new-modifiers)
|
||||||
(when (seq new-modifiers)
|
(tm/schedule #(st/emit! (dwt/set-modifiers-raw new-modifiers)))
|
||||||
(tm/schedule #(st/emit! (dwt/set-modifiers-raw new-modifiers))))
|
|
||||||
new-modifiers))))
|
new-modifiers))))
|
||||||
|
|
||||||
transforms
|
transforms
|
||||||
@ -480,7 +485,7 @@
|
|||||||
(mf/deps modifiers)
|
(mf/deps modifiers)
|
||||||
(fn []
|
(fn []
|
||||||
(js/console.log "****modifiers" (clj->js modifiers))
|
(js/console.log "****modifiers" (clj->js modifiers))
|
||||||
(when (seq modifiers)
|
(when (and (seq modifiers) (not ignore?))
|
||||||
(d/mapm (fn [id {modifiers :modifiers}]
|
(d/mapm (fn [id {modifiers :modifiers}]
|
||||||
(let [shape (get objects id)
|
(let [shape (get objects id)
|
||||||
center (gsh/center-shape shape)
|
center (gsh/center-shape shape)
|
||||||
@ -691,15 +696,16 @@
|
|||||||
(let [is-prev-val? (d/not-empty? @prev-modifiers)
|
(let [is-prev-val? (d/not-empty? @prev-modifiers)
|
||||||
is-cur-val? (d/not-empty? modifiers)]
|
is-cur-val? (d/not-empty? modifiers)]
|
||||||
|
|
||||||
(when (and (not is-prev-val?) is-cur-val?)
|
(when (and (not is-prev-val?) is-cur-val? (not ignore?))
|
||||||
(start-transform! node shapes))
|
(start-transform! node shapes))
|
||||||
|
|
||||||
(when is-cur-val?
|
(when (and is-cur-val? (not ignore?))
|
||||||
(update-transform! node shapes transforms modifiers))
|
(update-transform! node shapes transforms modifiers))
|
||||||
|
|
||||||
(when (and is-prev-val? (not is-cur-val?))
|
(when (and is-prev-val? (not is-cur-val?) (not ignore?))
|
||||||
(remove-transform! node @prev-shapes))
|
(remove-transform! node @prev-shapes))
|
||||||
|
|
||||||
(reset! prev-modifiers modifiers)
|
(reset! prev-modifiers modifiers)
|
||||||
(reset! prev-transforms transforms)
|
(reset! prev-transforms transforms)
|
||||||
(reset! prev-shapes shapes))))))
|
(reset! prev-shapes shapes)
|
||||||
|
(reset! changed-modifiers nil))))))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user