From 265675795edf00d8e223a09c90025d6ac7157f2f Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 26 Feb 2025 12:33:52 +0100 Subject: [PATCH] :bug: Fix problem resizing on click --- CHANGES.md | 1 + .../app/main/data/workspace/transforms.cljs | 58 +++++++++++-------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5b7e6ab5bf..1e56ed1f10 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ ### :bug: Bugs fixed - Fix opacity in frame containers [Github #5858](https://github.com/penpot/penpot/pull/5858) +- Avoid resizing on click [Taiga #10213](https://tree.taiga.io/project/penpot/issue/10213) ## 2.5.2 diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index caf83183fd..a6abb3ac97 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -275,31 +275,43 @@ (->> (snap/closest-snap-point page-id shapes objects layout zoom focus point) (rx/map #(conj current %))))) (rx/map #(resize shape initial-position layout %)) - (rx/share))] + (rx/share)) + + + modifiers-stream + (rx/merge + (->> resize-events-stream + (rx/mapcat + (fn [modifiers] + (let [modif-tree (dwm/create-modif-tree ids modifiers)] + (if (features/active-feature? state "render-wasm/v1") + (rx/of + (dwm/set-selrect-transform modifiers) + (dwm/set-wasm-modifiers modif-tree (contains? layout :scale-text))) + + (rx/of (dwm/set-modifiers modif-tree (contains? layout :scale-text))))))) + (rx/take-until stopper)) + + ;; The last event we need to use the old method so the elements are correctly positioned until + ;; all the logic is implemented in wasm + (if (features/active-feature? state "render-wasm/v1") + (->> resize-events-stream + (rx/take-until stopper) + (rx/last) + (rx/map #(dwm/apply-modifiers {:modifiers (dwm/create-modif-tree ids %) + :ignore-constraints (contains? layout :scale-text)}))) + (rx/empty)))] (rx/concat - (rx/merge - (->> resize-events-stream - (rx/mapcat - (fn [modifiers] - (let [modif-tree (dwm/create-modif-tree ids modifiers)] - (if (features/active-feature? state "render-wasm/v1") - (rx/of - (dwm/set-selrect-transform modifiers) - (dwm/set-wasm-modifiers modif-tree (contains? layout :scale-text))) - - (rx/of (dwm/set-modifiers modif-tree (contains? layout :scale-text))))))) - (rx/take-until stopper)) - - ;; The last event we need to use the old method so the elements are correctly positioned until - ;; all the logic is implemented in wasm - (if (features/active-feature? state "render-wasm/v1") - (->> resize-events-stream - (rx/take-until stopper) - (rx/last) - (rx/map #(dwm/apply-modifiers {:modifiers (dwm/create-modif-tree ids %) - :ignore-constraints (contains? layout :scale-text)}))) - (rx/empty))) + ;; This initial stream waits for some pixels to be move before making the resize + ;; if you make a click in the border will not make a resize + (->> ms/mouse-position + (rx/map #(gpt/to-vec initial-position %)) + (rx/map #(gpt/length %)) + (rx/filter #(> % (/ 10 zoom))) + (rx/take 1) + (rx/mapcat (fn [] modifiers-stream)) + (rx/take-until stopper)) (rx/of (if (features/active-feature? state "render-wasm/v1")