mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 10:38:13 -05:00
🐛 Fix intermitent exception on viewport ref ns
This commit is contained in:
parent
bf3888585a
commit
049ebdd542
1 changed files with 3 additions and 2 deletions
|
@ -39,7 +39,6 @@
|
|||
|
||||
(defn create-viewport-ref
|
||||
[]
|
||||
|
||||
(let [ref (mf/use-ref nil)]
|
||||
[ref
|
||||
(mf/use-memo
|
||||
|
@ -51,11 +50,13 @@
|
|||
(defn point->viewport
|
||||
[pt]
|
||||
(let [zoom (dm/get-in @st/state [:workspace-local :zoom])]
|
||||
(when (some? @viewport-ref)
|
||||
(when (and (some? @viewport-ref)
|
||||
(some? @viewport-brect))
|
||||
(let [vbox (.. ^js @viewport-ref -viewBox -baseVal)
|
||||
brect @viewport-brect
|
||||
box (gpt/point (.-x vbox) (.-y vbox))
|
||||
zoom (gpt/point zoom)]
|
||||
|
||||
(-> (gpt/subtract pt brect)
|
||||
(gpt/divide zoom)
|
||||
(gpt/add box))))))
|
||||
|
|
Loading…
Add table
Reference in a new issue