Skip to content

Commit

Permalink
feat(rotate): support snap angle when rotate with hotkey #WIK-15113
Browse files Browse the repository at this point in the history
  • Loading branch information
MissLixf committed Apr 18, 2024
1 parent 0648a6a commit ad787f9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .changeset/breezy-knives-tie.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@plait/draw': patch
'@plait/draw': minor
---

fix(draw): support snap angle when rotate with hotkey
feat(rotate): support snap angle when rotate with hotkey
1 change: 0 additions & 1 deletion packages/common/src/types/rotate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ export interface RotateRef<T extends PlaitElement = PlaitElement> {
elements: T[];
startPoint: Point;
angle?: number;
isShift?: boolean;
}
4 changes: 2 additions & 2 deletions packages/draw/src/plugins/with-draw-rotate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const withDrawRotate = (board: PlaitBoard) => {
board.pointerMove = (event: PointerEvent) => {
if (rotateRef) {
event.preventDefault();
rotateRef.isShift = !!event.shiftKey;
const isShift = !!event.shiftKey;
addRotating(board, rotateRef);
const endPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
const selectionRectangle = getRectangleByElements(board, rotateRef.elements, false);
Expand All @@ -75,7 +75,7 @@ export const withDrawRotate = (board: PlaitBoard) => {
throttleRAF(board, 'with-common-rotate', () => {
if (rotateRef && rotateRef.startPoint) {
let angle = getAngleBetweenPoints(rotateRef.startPoint, endPoint, selectionCenterPoint);
if (rotateRef.isShift) {
if (isShift) {
angle += Math.PI / 12 / 2;
angle -= angle % (Math.PI / 12);
}
Expand Down

0 comments on commit ad787f9

Please sign in to comment.