From 6780d17d2e5ee56757a06ea5a83912d9225353e2 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 28 Mar 2022 17:19:28 +0200 Subject: [PATCH] :bug: Fix drag guides to delete target area --- CHANGES.md | 1 + .../main/ui/workspace/viewport/guides.cljs | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 61e1cce47..f9e44c799 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -66,6 +66,7 @@ - Improved command support for MacOS [Taiga #2789](https://tree.taiga.io/project/penpot/issue/2789) - Fix shift+2 shortcut in MacOS with non-english keyboards [Taiga #3038](https://tree.taiga.io/project/penpot/issue/3038) - Some fixes to SVG imports [Taiga #3122](https://tree.taiga.io/project/penpot/issue/3122) [#1720](https://github.com/penpot/penpot/issues/1720) [Taiga #2884](https://tree.taiga.io/project/penpot/issue/2884) +- Fix drag guides to delete target area [#1679](https://github.com/penpot/penpot/issues/1679) ### :arrow_up: Deps updates ### :heart: Community contributions by (Thank you!) diff --git a/frontend/src/app/main/ui/workspace/viewport/guides.cljs b/frontend/src/app/main/ui/workspace/viewport/guides.cljs index c12d31850..434458d31 100644 --- a/frontend/src/app/main/ui/workspace/viewport/guides.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/guides.cljs @@ -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)))))]