mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 21:46:38 +02:00
Get precision bug on mouse stream on workspace.
This commit is contained in:
parent
36dd831a69
commit
f8aaba6f31
2 changed files with 9 additions and 8 deletions
|
@ -16,6 +16,7 @@
|
|||
[uxbox.ui.mixins :as mx]
|
||||
[uxbox.util.geom.point :as gpt]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.data :refer (parse-int)]
|
||||
[uxbox.ui.keyboard :as kbd]
|
||||
[uxbox.ui.workspace.base :as wb]
|
||||
[uxbox.ui.workspace.canvas.movement]
|
||||
|
@ -179,14 +180,16 @@
|
|||
(letfn [(translate-point-to-viewport [pt]
|
||||
(let [viewport (mx/get-ref-dom own "viewport")
|
||||
brect (.getBoundingClientRect viewport)
|
||||
brect (gpt/point (.-left brect) (.-top brect))]
|
||||
brect (gpt/point (parse-int (.-left brect))
|
||||
(parse-int (.-top brect)))]
|
||||
(gpt/subtract pt brect)))
|
||||
|
||||
(translate-point-to-canvas [pt]
|
||||
(let [viewport (mx/get-ref-dom own "viewport")
|
||||
canvas (dom/get-element-by-class "page-canvas" viewport)
|
||||
brect (.getBoundingClientRect canvas)
|
||||
brect (gpt/point (.-left brect) (.-top brect))]
|
||||
brect (gpt/point (parse-int (.-left brect))
|
||||
(parse-int (.-top brect)))]
|
||||
(gpt/subtract pt brect)))
|
||||
|
||||
(on-key-down [event]
|
||||
|
|
|
@ -19,12 +19,10 @@
|
|||
(defn- coordenates-render
|
||||
[own]
|
||||
(when-let [{:keys [x y]} (rum/react wb/mouse-canvas-a)]
|
||||
(let [x (mth/precision x 1)
|
||||
y (mth/precision y 1)]
|
||||
(html
|
||||
[:ul.options-btn
|
||||
[:li.tooltip.tooltip-bottom {:alt "x"} x]
|
||||
[:li.tooltip.tooltip-bottom {:alt "y"} y]]))))
|
||||
(html
|
||||
[:ul.options-btn
|
||||
[:li.tooltip.tooltip-bottom {:alt "x"} x]
|
||||
[:li.tooltip.tooltip-bottom {:alt "y"} y]])))
|
||||
|
||||
(def coordinates
|
||||
(mx/component
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue