mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 21:09:00 -05:00
Add horizontal resize handlers (#25)
This commit is contained in:
parent
c88e5fc266
commit
15d5748922
3 changed files with 57 additions and 9 deletions
|
@ -50,6 +50,10 @@
|
||||||
circle.bottom-right { cursor: nwse-resize; }
|
circle.bottom-right { cursor: nwse-resize; }
|
||||||
circle.top-right { cursor: nesw-resize; }
|
circle.top-right { cursor: nesw-resize; }
|
||||||
circle.bottom-left { cursor: nesw-resize; }
|
circle.bottom-left { cursor: nesw-resize; }
|
||||||
|
rect.top { cursor: ns-resize; }
|
||||||
|
rect.bottom { cursor: ns-resize; }
|
||||||
|
rect.left { cursor: ew-resize; }
|
||||||
|
rect.right { cursor: ew-resize; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,38 @@
|
||||||
[:rect {:x x :y y :width width :height height :stroke-dasharray "5,5"
|
[:rect {:x x :y y :width width :height height :stroke-dasharray "5,5"
|
||||||
:style {:stroke "#333" :fill "transparent"
|
:style {:stroke "#333" :fill "transparent"
|
||||||
:stroke-opacity "1"}}]
|
:stroke-opacity "1"}}]
|
||||||
|
[:rect.top
|
||||||
|
{:fill "#333"
|
||||||
|
:on-mouse-up #(on-mouse-up 5 %)
|
||||||
|
:on-mouse-down #(on-mouse-down 5 %)
|
||||||
|
:x (- (+ x (/ width 2)) 7)
|
||||||
|
:width 14
|
||||||
|
:height 3
|
||||||
|
:y (- y 5)}]
|
||||||
|
[:rect.right
|
||||||
|
{:fill "#333"
|
||||||
|
:on-mouse-up #(on-mouse-up 6 %)
|
||||||
|
:on-mouse-down #(on-mouse-down 6 %)
|
||||||
|
:y (- (+ y (/ height 2)) 7)
|
||||||
|
:width 3
|
||||||
|
:height 14
|
||||||
|
:x (+ x width 2)}]
|
||||||
|
[:rect.bottom
|
||||||
|
{:fill "#333"
|
||||||
|
:on-mouse-up #(on-mouse-up 7 %)
|
||||||
|
:on-mouse-down #(on-mouse-down 7 %)
|
||||||
|
:x (- (+ x (/ width 2)) 7)
|
||||||
|
:width 14
|
||||||
|
:height 3
|
||||||
|
:y (+ y height 2)}]
|
||||||
|
[:rect.left
|
||||||
|
{:fill "#333"
|
||||||
|
:on-mouse-up #(on-mouse-up 8 %)
|
||||||
|
:on-mouse-down #(on-mouse-down 8 %)
|
||||||
|
:y (- (+ y (/ height 2)) 7)
|
||||||
|
:width 3
|
||||||
|
:height 14
|
||||||
|
:x (- x 5)}]
|
||||||
[:circle.top-left
|
[:circle.top-left
|
||||||
(merge uusc/+circle-props+
|
(merge uusc/+circle-props+
|
||||||
{:on-mouse-up #(on-mouse-up 1 %)
|
{:on-mouse-up #(on-mouse-up 1 %)
|
||||||
|
|
|
@ -195,7 +195,15 @@
|
||||||
:y2 (max y1 (+ y2 dy)))
|
:y2 (max y1 (+ y2 dy)))
|
||||||
4 (assoc shape
|
4 (assoc shape
|
||||||
:x2 (max x1 (+ x2 dx))
|
:x2 (max x1 (+ x2 dx))
|
||||||
:y2 (max y1 (+ y2 dy))))))
|
:y2 (max y1 (+ y2 dy)))
|
||||||
|
5 (assoc shape
|
||||||
|
:y1 (min y2 (+ y1 dy)))
|
||||||
|
6 (assoc shape
|
||||||
|
:x2 (max x1 (+ x2 dx)))
|
||||||
|
7 (assoc shape
|
||||||
|
:y2 (max y1 (+ y2 dy)))
|
||||||
|
8 (assoc shape
|
||||||
|
:x1 (min x2 (+ x1 dx))))))
|
||||||
|
|
||||||
(defn- move-circle-vertex
|
(defn- move-circle-vertex
|
||||||
"A specialized function for vertex movement
|
"A specialized function for vertex movement
|
||||||
|
@ -204,17 +212,21 @@
|
||||||
(let [[dx dy] (if lock [dx dx] [dx dy])]
|
(let [[dx dy] (if lock [dx dx] [dx dy])]
|
||||||
(case vid
|
(case vid
|
||||||
1 (assoc shape
|
1 (assoc shape
|
||||||
:rx (- (:rx shape) dx)
|
:rx (max 0 (- (:rx shape) dx))
|
||||||
:ry (- (:ry shape) dy))
|
:ry (max 0 (- (:ry shape) dy)))
|
||||||
2 (assoc shape
|
2 (assoc shape
|
||||||
:rx (+ (:rx shape) dx)
|
:rx (max 0 (+ (:rx shape) dx))
|
||||||
:ry (- (:ry shape) dy))
|
:ry (max 0 (- (:ry shape) dy)))
|
||||||
3 (assoc shape
|
3 (assoc shape
|
||||||
:rx (- (:rx shape) dx)
|
:rx (max 0 (- (:rx shape) dx))
|
||||||
:ry (+ (:ry shape) dy))
|
:ry (max 0 (+ (:ry shape) dy)))
|
||||||
4 (assoc shape
|
4 (assoc shape
|
||||||
:rx (+ (:rx shape) dx)
|
:rx (max 0 (+ (:rx shape) dx))
|
||||||
:ry (+ (:ry shape) dy)))))
|
:ry (max 0 (+ (:ry shape) dy)))
|
||||||
|
5 (assoc shape :ry (max 0 (- (:ry shape) dy)))
|
||||||
|
6 (assoc shape :rx (max 0 (+ (:rx shape) dx)))
|
||||||
|
7 (assoc shape :ry (max 0 (+ (:ry shape) dy)))
|
||||||
|
8 (assoc shape :rx (max 0 (+ (:rx shape) dx))))))
|
||||||
|
|
||||||
;; --- Resize (Absolute)
|
;; --- Resize (Absolute)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue