0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Merge pull request #2814 from penpot/alotor-polishing-8

Fix some mask issues
This commit is contained in:
Alejandro 2023-01-20 14:04:45 +01:00 committed by GitHub
commit dad5d953ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 14 deletions

View file

@ -132,7 +132,7 @@
children (cph/get-immediate-children objects shape-id)]
(cond
(cph/mask-shape? shape)
(and (cph/mask-shape? shape) (seq children))
(get-group-bounds objects bounds modif-tree (-> children first))
(cph/group-shape? shape)

View file

@ -200,21 +200,9 @@
(cph/insert-at-index prev-shapes index shapes)
(cph/append-at-the-end prev-shapes shapes))))
(check-insert-items [prev-shapes parent index shapes]
(if-not (:masked-group? parent)
(insert-items prev-shapes index shapes)
;; For masked groups, the first shape is the mask
;; and it cannot be moved.
(let [mask-id (first prev-shapes)
other-ids (rest prev-shapes)
not-mask-shapes (without-obj shapes mask-id)
new-index (if (nil? index) nil (max (dec index) 0))
new-shapes (insert-items other-ids new-index not-mask-shapes)]
(into [mask-id] new-shapes))))
(add-to-parent [parent index shapes]
(let [parent (-> parent
(update :shapes check-insert-items parent index shapes)
(update :shapes insert-items index shapes)
;; We need to ensure that no `nil` in the
;; shapes list after adding all the
;; incoming shapes to the parent.

View file

@ -78,6 +78,13 @@
:y (:y mask-bb-rect)
:width (:width mask-bb-rect)
:height (:height mask-bb-rect)
;; This is necesary to prevent a race condition in the dynamic-modifiers whether the modifier
;; triggers afte the render
:data-old-x (:x mask-bb-rect)
:data-old-y (:y mask-bb-rect)
:data-old-width (:width mask-bb-rect)
:data-old-height (:height mask-bb-rect)
:mask-units "userSpaceOnUse"}
[:g {:filter (when-not svg-text? (filter-url render-id mask))}
[:& shape-wrapper {:shape (-> mask (dissoc :shadow :blur) (assoc :is-mask? true))}]]]])))