mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 07:29:08 -05:00
🐛 Fix problem with masks interactions outside bounds
This commit is contained in:
parent
2a4849cf8f
commit
e1df3efd6e
3 changed files with 22 additions and 5 deletions
|
@ -23,6 +23,7 @@
|
||||||
- Fix problem with system shortcuts and application [#737](https://github.com/penpot/penpot/issues/737)
|
- Fix problem with system shortcuts and application [#737](https://github.com/penpot/penpot/issues/737)
|
||||||
- Fix issue with typographies panel cannot be collapsed [#707](https://github.com/penpot/penpot/issues/707)
|
- Fix issue with typographies panel cannot be collapsed [#707](https://github.com/penpot/penpot/issues/707)
|
||||||
- Fix problem with middle mouse button press moving the canvas when not moving mouse [#717](https://github.com/penpot/penpot/issues/717)
|
- Fix problem with middle mouse button press moving the canvas when not moving mouse [#717](https://github.com/penpot/penpot/issues/717)
|
||||||
|
- Fix problem with masks interactions outside bounds [#718](https://github.com/penpot/penpot/issues/718)
|
||||||
|
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.main.ui.shapes.mask :refer [mask-str mask-factory]]))
|
[app.main.ui.shapes.mask :refer [mask-str clip-str mask-factory]]))
|
||||||
|
|
||||||
(defn group-shape
|
(defn group-shape
|
||||||
[shape-wrapper]
|
[shape-wrapper]
|
||||||
|
@ -35,6 +35,7 @@
|
||||||
props (-> (attrs/extract-style-attrs shape)
|
props (-> (attrs/extract-style-attrs shape)
|
||||||
(obj/merge!
|
(obj/merge!
|
||||||
#js {:pointerEvents pointer-events
|
#js {:pointerEvents pointer-events
|
||||||
|
:clipPath (when (and mask (not expand-mask)) (clip-str mask))
|
||||||
:mask (when (and mask (not expand-mask)) (mask-str mask))}))]
|
:mask (when (and mask (not expand-mask)) (mask-str mask))}))]
|
||||||
|
|
||||||
[:> :g props
|
[:> :g props
|
||||||
|
|
|
@ -10,18 +10,25 @@
|
||||||
(ns app.main.ui.shapes.mask
|
(ns app.main.ui.shapes.mask
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]
|
||||||
|
[app.common.geom.shapes :as gsh]))
|
||||||
|
|
||||||
(defn mask-str [mask]
|
(defn mask-str [mask]
|
||||||
(str/fmt "url(#%s)" (str (:id mask) "-mask")))
|
(str/fmt "url(#%s)" (str (:id mask) "-mask")))
|
||||||
|
|
||||||
|
(defn clip-str [mask]
|
||||||
|
(str/fmt "url(#%s)" (str (:id mask) "-clip")))
|
||||||
|
|
||||||
(defn mask-factory
|
(defn mask-factory
|
||||||
[shape-wrapper]
|
[shape-wrapper]
|
||||||
(mf/fnc mask-shape
|
(mf/fnc mask-shape
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [frame (unchecked-get props "frame")
|
(let [frame (unchecked-get props "frame")
|
||||||
mask (unchecked-get props "mask")]
|
mask (unchecked-get props "mask")
|
||||||
|
mask' (-> mask
|
||||||
|
(gsh/transform-shape)
|
||||||
|
(gsh/translate-to-frame frame))]
|
||||||
[:defs
|
[:defs
|
||||||
[:filter {:id (str (:id mask) "-filter")}
|
[:filter {:id (str (:id mask) "-filter")}
|
||||||
[:feFlood {:flood-color "white"
|
[:feFlood {:flood-color "white"
|
||||||
|
@ -30,8 +37,16 @@
|
||||||
:in2 "SourceGraphic"
|
:in2 "SourceGraphic"
|
||||||
:operator "in"
|
:operator "in"
|
||||||
:result "comp"}]]
|
:result "comp"}]]
|
||||||
|
;; Clip path is necesary so the elements inside the mask won't affect
|
||||||
|
;; the events outside. Clip hides the elements but mask doesn't (like display vs visibility)
|
||||||
|
;; we cannot use clips instead of mask because clips can only be simple shapes
|
||||||
|
[:clipPath {:id (str (:id mask) "-clip")}
|
||||||
|
[:polyline {:points (->> (:points mask')
|
||||||
|
(map #(str (:x %) "," (:y %)))
|
||||||
|
(str/join " "))}]]
|
||||||
[:mask {:id (str (:id mask) "-mask")}
|
[:mask {:id (str (:id mask) "-mask")}
|
||||||
[:g {:filter (str/fmt "url(#%s)" (str (:id mask) "-filter"))}
|
[:g {:filter (str/fmt "url(#%s)" (str (:id mask) "-filter"))}
|
||||||
[:& shape-wrapper {:frame frame :shape (-> mask
|
[:& shape-wrapper {:frame frame
|
||||||
|
:shape (-> mask
|
||||||
(dissoc :shadow :blur))}]]]])))
|
(dissoc :shadow :blur))}]]]])))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue