mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 19:36:37 +02:00
🐛 Fix problem with non-clip shapes and zoom
This commit is contained in:
parent
792145353e
commit
72e29e58d2
1 changed files with 24 additions and 10 deletions
|
@ -12,9 +12,11 @@
|
||||||
others are defined using a generic wrapper implemented in
|
others are defined using a generic wrapper implemented in
|
||||||
common."
|
common."
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.files.helpers :as cfh]
|
[app.common.files.helpers :as cfh]
|
||||||
[app.common.geom.rect :as grc]
|
[app.common.geom.rect :as grc]
|
||||||
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.ui.context :as ctx]
|
[app.main.ui.context :as ctx]
|
||||||
[app.main.ui.shapes.circle :as circle]
|
[app.main.ui.shapes.circle :as circle]
|
||||||
|
@ -42,22 +44,34 @@
|
||||||
(def image-wrapper (common/generic-wrapper-factory image/image-shape))
|
(def image-wrapper (common/generic-wrapper-factory image/image-shape))
|
||||||
(def rect-wrapper (common/generic-wrapper-factory rect/rect-shape))
|
(def rect-wrapper (common/generic-wrapper-factory rect/rect-shape))
|
||||||
|
|
||||||
|
(defn- make-is-frame-overlap
|
||||||
|
[vbox objects]
|
||||||
|
(fn [shape]
|
||||||
|
(let [bounds
|
||||||
|
(if (dm/get-prop shape :show-content)
|
||||||
|
(let [children (->> (cfh/get-children-ids objects (dm/get-prop shape :id))
|
||||||
|
(map (d/getf objects)))]
|
||||||
|
(gsh/shapes->rect (cons shape children)))
|
||||||
|
(dm/get-prop shape :selrect))]
|
||||||
|
(grc/overlaps-rects? vbox bounds))))
|
||||||
|
|
||||||
(mf/defc root-shape
|
(mf/defc root-shape
|
||||||
"Draws the root shape of the viewport and recursively all the shapes"
|
"Draws the root shape of the viewport and recursively all the shapes"
|
||||||
{::mf/wrap [mf/memo]
|
{::mf/wrap [mf/memo]
|
||||||
::mf/wrap-props false}
|
::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [objects (obj/get props "objects")
|
(let [objects (obj/get props "objects")
|
||||||
active-frames (obj/get props "active-frames")
|
active-frames (obj/get props "active-frames")
|
||||||
shapes (cfh/get-immediate-children objects)
|
shapes (cfh/get-immediate-children objects)
|
||||||
vbox (mf/use-ctx ctx/current-vbox)
|
vbox (mf/use-ctx ctx/current-vbox)
|
||||||
|
|
||||||
shapes (mf/with-memo [shapes vbox]
|
frame-overlap? (mf/with-memo [vbox objects]
|
||||||
(if (some? vbox)
|
#(make-is-frame-overlap vbox objects))
|
||||||
(filter (fn [shape]
|
|
||||||
(grc/overlaps-rects? vbox (dm/get-prop shape :selrect)))
|
shapes (mf/with-memo [shapes vbox frame-overlap?]
|
||||||
shapes)
|
(cond->> shapes
|
||||||
shapes))]
|
(some? vbox)
|
||||||
|
(filter frame-overlap?)))]
|
||||||
|
|
||||||
[:g {:id (dm/str "shape-" uuid/zero)}
|
[:g {:id (dm/str "shape-" uuid/zero)}
|
||||||
[:& (mf/provider ctx/active-frames) {:value active-frames}
|
[:& (mf/provider ctx/active-frames) {:value active-frames}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue