mirror of
https://github.com/penpot/penpot.git
synced 2025-06-11 03:21:39 +02: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 selection-rect-width 1)
|
||||||
(def min-selrect-side 10)
|
(def min-selrect-side 10)
|
||||||
(def small-selrect-side 30)
|
(def small-selrect-side 30)
|
||||||
|
(def min-selrect-width 10)
|
||||||
|
(def min-selrect-height 10)
|
||||||
|
|
||||||
(mf/defc selection-rect
|
(mf/defc selection-rect
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
|
@ -43,12 +45,27 @@
|
||||||
(let [x (dm/get-prop rect :x)
|
(let [x (dm/get-prop rect :x)
|
||||||
y (dm/get-prop rect :y)
|
y (dm/get-prop rect :y)
|
||||||
width (dm/get-prop rect :width)
|
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
|
[:rect.main.viewport-selrect
|
||||||
{:x x
|
{:x x
|
||||||
:y y
|
:y y
|
||||||
:width width
|
:width (max width (/ 10 zoom))
|
||||||
:height height
|
:height (max height (/ 10 zoom))
|
||||||
:transform (str transform)
|
:transform (str transform)
|
||||||
:on-pointer-down on-move-selected
|
:on-pointer-down on-move-selected
|
||||||
:on-context-menu on-context-menu
|
:on-context-menu on-context-menu
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue