0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00

🐛 Fix geometry sync for subcomponents

This commit is contained in:
Andrés Moya 2021-07-01 16:55:31 +02:00 committed by Alonso Torres
parent 5f1ed511ea
commit c98958053c

View file

@ -631,20 +631,14 @@
set-remote-synced?))) set-remote-synced?)))
both (fn [child-inst child-main] both (fn [child-inst child-main]
(let [sub-root? (and (:component-id shape-inst)
(not (:component-root? shape-inst)))]
(generate-sync-shape-direct-recursive container (generate-sync-shape-direct-recursive container
child-inst child-inst
component component
child-main child-main
(if sub-root? root-inst
shape-inst root-main
root-inst)
(if sub-root?
shape-main
root-main)
reset? reset?
initial-root?))) initial-root?))
moved (fn [child-inst child-main] moved (fn [child-inst child-main]
(move-shape (move-shape
@ -752,20 +746,13 @@
false)) false))
both (fn [child-inst child-main] both (fn [child-inst child-main]
(let [sub-root? (and (:component-id shape-inst)
(not (:component-root? shape-inst)))]
(generate-sync-shape-inverse-recursive container (generate-sync-shape-inverse-recursive container
child-inst child-inst
component component
child-main child-main
(if sub-root? root-inst
shape-inst root-main
root-inst) initial-root?))
(if sub-root?
shape-main
root-main)
initial-root?)))
moved (fn [child-inst child-main] moved (fn [child-inst child-main]
(move-shape (move-shape
@ -1160,6 +1147,8 @@
; sync only the position relative to the origin of the component. ; sync only the position relative to the origin of the component.
; We solve this by moving the origin shape so it is aligned with ; We solve this by moving the origin shape so it is aligned with
; the dest root before syncing. ; the dest root before syncing.
; In case of subinstances, the comparison is always done with the
; near component, because this is that we are syncing with.
origin-shape (reposition-shape origin-shape origin-root dest-root) origin-shape (reposition-shape origin-shape origin-root dest-root)
touched (get dest-shape :touched #{})] touched (get dest-shape :touched #{})]