mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -05:00
🐛 Fix snap index problem
This commit is contained in:
parent
50bdcea81b
commit
c1278194ce
2 changed files with 29 additions and 6 deletions
|
@ -6,6 +6,7 @@
|
|||
### :bug: Bugs fixed
|
||||
|
||||
- Remove interactions when the destination artboard is deleted [Taiga #1656](https://tree.taiga.io/project/penpot/issue/1656)
|
||||
- Fix snap index problem [Taiga #1661](https://tree.taiga.io/project/penpot/issue/1661)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
### :boom: Breaking changes
|
||||
|
|
|
@ -69,8 +69,9 @@
|
|||
(let [shapes-data (aggregate-data objects)
|
||||
|
||||
create-index
|
||||
(fn [frame-id shapes] {:x (add-coord-data (rt/make-tree) frame-id shapes :x)
|
||||
:y (add-coord-data (rt/make-tree) frame-id shapes :y)})]
|
||||
(fn [frame-id shapes]
|
||||
{:x (-> (rt/make-tree) (add-coord-data frame-id shapes :x))
|
||||
:y (-> (rt/make-tree) (add-coord-data frame-id shapes :y))})]
|
||||
|
||||
(d/mapm create-index shapes-data)))
|
||||
|
||||
|
@ -78,6 +79,14 @@
|
|||
[snap-data old-objects new-objects]
|
||||
|
||||
(let [changed? #(not= (get old-objects %) (get new-objects %))
|
||||
is-deleted-frame? #(and (not= uuid/zero %)
|
||||
(contains? old-objects %)
|
||||
(not (contains? new-objects %))
|
||||
(= :frame (get-in old-objects [% :type])))
|
||||
is-new-frame? #(and (not= uuid/zero %)
|
||||
(contains? new-objects %)
|
||||
(not (contains? old-objects %))
|
||||
(= :frame (get-in new-objects [% :type])))
|
||||
|
||||
changed-ids (into #{}
|
||||
(filter changed?)
|
||||
|
@ -86,6 +95,9 @@
|
|||
to-delete (aggregate-data old-objects changed-ids)
|
||||
to-add (aggregate-data new-objects changed-ids)
|
||||
|
||||
frames-to-delete (->> changed-ids (filter is-deleted-frame?))
|
||||
frames-to-add (->> changed-ids (filter is-new-frame?))
|
||||
|
||||
delete-data
|
||||
(fn [snap-data [frame-id shapes]]
|
||||
(-> snap-data
|
||||
|
@ -98,11 +110,21 @@
|
|||
(update-in [frame-id :x] add-coord-data frame-id shapes :x)
|
||||
(update-in [frame-id :y] add-coord-data frame-id shapes :y)))
|
||||
|
||||
snap-data (->> to-delete
|
||||
(reduce delete-data snap-data))
|
||||
delete-frames
|
||||
(fn [snap-data frame-id]
|
||||
(dissoc snap-data frame-id))
|
||||
|
||||
snap-data (->> to-add
|
||||
(reduce add-data snap-data))]
|
||||
add-frames
|
||||
(fn [snap-data frame-id]
|
||||
(assoc snap-data frame-id {:x (rt/make-tree)
|
||||
:y (rt/make-tree)}))
|
||||
|
||||
snap-data (as-> snap-data $
|
||||
(reduce add-frames $ frames-to-add)
|
||||
(reduce add-data $ to-add)
|
||||
(reduce delete-data $ to-delete)
|
||||
(reduce delete-frames $ frames-to-delete))
|
||||
]
|
||||
|
||||
snap-data))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue