mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -05:00
🐛 Fix problem when moving horizontal/vertical lines
This commit is contained in:
parent
b7c4cb1f58
commit
27010ae0fb
1 changed files with 20 additions and 3 deletions
|
@ -36,6 +36,8 @@
|
|||
(def selection-rect-width 1)
|
||||
(def min-selrect-side 10)
|
||||
(def small-selrect-side 30)
|
||||
(def min-selrect-width 10)
|
||||
(def min-selrect-height 10)
|
||||
|
||||
(mf/defc selection-rect
|
||||
{::mf/wrap-props false}
|
||||
|
@ -43,12 +45,27 @@
|
|||
(let [x (dm/get-prop rect :x)
|
||||
y (dm/get-prop rect :y)
|
||||
width (dm/get-prop rect :width)
|
||||
height (dm/get-prop rect :height)]
|
||||
height (dm/get-prop rect :height)
|
||||
|
||||
;; This is a calculation to create a "minimum" interactable rect
|
||||
;; Is necesary so that small shapes in x/y (like lines) can be moved
|
||||
;; better
|
||||
[x width]
|
||||
(if (< width (/ min-selrect-width zoom))
|
||||
(let [width' (/ min-selrect-width zoom)]
|
||||
[(- x (/ (- width' width) 2)) width'])
|
||||
[x width])
|
||||
|
||||
[y height]
|
||||
(if (< height (/ min-selrect-height zoom))
|
||||
(let [height' (/ min-selrect-height zoom)]
|
||||
[(- y (/ (- height' height) 2)) height'])
|
||||
[y height])]
|
||||
[:rect.main.viewport-selrect
|
||||
{:x x
|
||||
:y y
|
||||
:width width
|
||||
:height height
|
||||
:width (max width (/ 10 zoom))
|
||||
:height (max height (/ 10 zoom))
|
||||
:transform (str transform)
|
||||
:on-pointer-down on-move-selected
|
||||
:on-context-menu on-context-menu
|
||||
|
|
Loading…
Add table
Reference in a new issue