mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 23:31:21 -05:00
wip roto 2
This commit is contained in:
parent
de4c7762ad
commit
835ed342f8
1 changed files with 22 additions and 16 deletions
|
@ -446,33 +446,38 @@
|
|||
(let [prev-shapes (mf/use-var nil)
|
||||
prev-modifiers (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
|
||||
(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 []
|
||||
(when-not @unflag
|
||||
(if ignore?
|
||||
{}
|
||||
(let [shapes (->> (keys modifiers)
|
||||
(mapv (d/getf objects)))]
|
||||
(get-copies shapes objects modifiers)))))
|
||||
|
||||
modifiers
|
||||
(mf/use-memo
|
||||
(mf/deps objects modifiers copies @unflag)
|
||||
(mf/deps objects modifiers copies)
|
||||
(fn []
|
||||
(if @unflag
|
||||
(do
|
||||
(reset! unflag false)
|
||||
modifiers)
|
||||
(if ignore?
|
||||
modifiers
|
||||
(let [new-modifiers (add-copies-modifiers copies objects modifiers)]
|
||||
(js/console.log "==================")
|
||||
(js/console.log "modifiers (antes)" (clj->js modifiers))
|
||||
(js/console.log "copies" (clj->js copies))
|
||||
(js/console.log "modifiers (después)" (clj->js new-modifiers))
|
||||
(reset! unflag true)
|
||||
(when (seq new-modifiers)
|
||||
(tm/schedule #(st/emit! (dwt/set-modifiers-raw new-modifiers))))
|
||||
(reset! changed-modifiers new-modifiers)
|
||||
(tm/schedule #(st/emit! (dwt/set-modifiers-raw new-modifiers)))
|
||||
new-modifiers))))
|
||||
|
||||
transforms
|
||||
|
@ -480,7 +485,7 @@
|
|||
(mf/deps modifiers)
|
||||
(fn []
|
||||
(js/console.log "****modifiers" (clj->js modifiers))
|
||||
(when (seq modifiers)
|
||||
(when (and (seq modifiers) (not ignore?))
|
||||
(d/mapm (fn [id {modifiers :modifiers}]
|
||||
(let [shape (get objects id)
|
||||
center (gsh/center-shape shape)
|
||||
|
@ -691,15 +696,16 @@
|
|||
(let [is-prev-val? (d/not-empty? @prev-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))
|
||||
|
||||
(when is-cur-val?
|
||||
(when (and is-cur-val? (not ignore?))
|
||||
(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))
|
||||
|
||||
(reset! prev-modifiers modifiers)
|
||||
(reset! prev-transforms transforms)
|
||||
(reset! prev-shapes shapes))))))
|
||||
(reset! prev-shapes shapes)
|
||||
(reset! changed-modifiers nil))))))
|
||||
|
|
Loading…
Add table
Reference in a new issue