mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
✨ Rotation to snap to 15º intervals with shift
This commit is contained in:
parent
10598063d1
commit
fc2399a885
2 changed files with 11 additions and 10 deletions
|
@ -5,7 +5,7 @@
|
|||
### :boom: Breaking changes
|
||||
|
||||
### :sparkles: New features
|
||||
|
||||
- Rotation to snap to 15º intervals with shift [Taiga #2437](https://tree.taiga.io/project/penpot/issue/2437)
|
||||
- Support border radius and stroke properties for images [Taiga #497](https://tree.taiga.io/project/penpot/us/497)
|
||||
- Disallow using same password as user email [Taiga #2454](https://tree.taiga.io/project/penpot/us/2454)
|
||||
- Add configurable nudge amount [Taiga #910](https://tree.taiga.io/project/penpot/us/910)
|
||||
|
|
|
@ -432,24 +432,25 @@
|
|||
group (gsh/selection-rect shapes)
|
||||
group-center (gsh/center-selrect group)
|
||||
initial-angle (gpt/angle @ms/mouse-position group-center)
|
||||
calculate-angle (fn [pos ctrl?]
|
||||
calculate-angle (fn [pos ctrl? shift?]
|
||||
(let [angle (- (gpt/angle pos group-center) initial-angle)
|
||||
angle (if (neg? angle) (+ 360 angle) angle)
|
||||
modval (mod angle 45)
|
||||
angle (if ctrl?
|
||||
(if (< 22.5 modval)
|
||||
(+ angle (- 45 modval))
|
||||
(- angle modval))
|
||||
angle)
|
||||
angle (if (= angle 360)
|
||||
0
|
||||
angle)
|
||||
angle (if ctrl?
|
||||
(* (mth/floor (/ angle 45)) 45)
|
||||
angle)
|
||||
angle (if shift?
|
||||
(* (mth/floor (/ angle 15)) 15)
|
||||
angle)]
|
||||
angle))]
|
||||
(rx/concat
|
||||
(->> ms/mouse-position
|
||||
(rx/with-latest vector ms/mouse-position-ctrl)
|
||||
(rx/map (fn [[pos ctrl?]]
|
||||
(let [delta-angle (calculate-angle pos ctrl?)]
|
||||
(rx/with-latest vector ms/mouse-position-shift)
|
||||
(rx/map (fn [[[pos ctrl?] shift?]]
|
||||
(let [delta-angle (calculate-angle pos ctrl? shift?)]
|
||||
(set-rotation-modifiers delta-angle shapes group-center))))
|
||||
(rx/take-until stoper))
|
||||
(rx/of (apply-modifiers (map :id shapes))
|
||||
|
|
Loading…
Reference in a new issue