From aa276ab3081b7f5b73109e6fc05d26c63017f266 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 8 Nov 2021 16:11:05 +0100 Subject: [PATCH] :bug: Fix viewer comment position when zoom applied --- CHANGES.md | 1 + frontend/src/app/main/ui/viewer/comments.cljs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 45bce8bcb..8a9078360 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -23,6 +23,7 @@ - Add shortcuts to boolean icons popups [Taiga #2220](https://tree.taiga.io/project/penpot/issue/2220) - Fix a worker error when transforming a rectangle into path - Fix max/min values for opacity fields [Taiga #2183](https://tree.taiga.io/project/penpot/issue/2183) +- Fix viewer comment position when zoom applied [Taiga #2240](https://tree.taiga.io/project/penpot/issue/2240) ### :arrow_up: Deps updates ### :heart: Community contributions by (Thank you!) diff --git a/frontend/src/app/main/ui/viewer/comments.cljs b/frontend/src/app/main/ui/viewer/comments.cljs index 096237a10..7d547383d 100644 --- a/frontend/src/app/main/ui/viewer/comments.cljs +++ b/frontend/src/app/main/ui/viewer/comments.cljs @@ -105,14 +105,15 @@ on-click (mf/use-callback - (mf/deps cstate frame page file) + (mf/deps cstate frame page file zoom) (fn [event] (dom/stop-propagation event) (if (some? (:open cstate)) (st/emit! (dcm/close-thread)) (let [event (.-nativeEvent ^js event) - position (-> (dom/get-offset-position event) - (gpt/transform modifier2)) + viewport-point (dom/get-offset-position event) + viewport-point (-> viewport-point (update :x #(/ % zoom)) (update :y #(/ % zoom))) + position (gpt/transform viewport-point modifier2) params {:position position :page-id (:id page) :file-id (:id file)}]