🐛 Fix drag guides to delete target area

This commit is contained in:
alonso.torres 2022-03-28 17:19:28 +02:00 committed by Andrés Moya
parent af22fee0c1
commit 6780d17d2e
2 changed files with 11 additions and 9 deletions

View file

@ -215,18 +215,19 @@
:text-y pos})))
(defn guide-inside-vbox?
([vbox]
(partial guide-inside-vbox? vbox))
([zoom vbox]
(partial guide-inside-vbox? zoom vbox))
([{:keys [x y width height]} {:keys [axis position]}]
(let [x1 x
([zoom {:keys [x y width height]} {:keys [axis position]}]
(let [rule-area-size (/ rules/rule-area-size zoom)
x1 x
x2 (+ x width)
y1 y
y2 (+ y height)]
(if (= axis :x)
(and (>= position x1)
(and (>= position (+ x1 rule-area-size))
(<= position x2))
(and (>= position y1)
(and (>= position (+ y1 rule-area-size))
(<= position y2))))))
(defn guide-creation-area
@ -383,7 +384,7 @@
(let [guide (-> guide
(assoc :id (uuid/next)
:axis axis))]
(when (guide-inside-vbox? vbox guide)
(when (guide-inside-vbox? zoom vbox guide)
(st/emit! (dw/update-guides guide))))))
{:keys [on-pointer-enter
@ -431,7 +432,7 @@
(mf/deps page vbox)
#(->> (get-in page [:options :guides] {})
(vals)
(filter (guide-inside-vbox? vbox))))
(filter (guide-inside-vbox? zoom vbox))))
focus (mf/deref refs/workspace-focus-selected)
@ -448,7 +449,7 @@
(mf/use-callback
(mf/deps vbox)
(fn [guide]
(if (guide-inside-vbox? vbox guide)
(if (guide-inside-vbox? zoom vbox guide)
(st/emit! (dw/update-guides guide))
(st/emit! (dw/remove-guide guide)))))]