Skip to content

Commit

Permalink
refactor: Use shared function for intransient states
Browse files Browse the repository at this point in the history
  • Loading branch information
miyanokomiya committed Feb 8, 2024
1 parent 4fc4fc8 commit 2620c07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
9 changes: 8 additions & 1 deletion src/composables/states/appCanvas/arrow/arrowSelectedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ export function newArrowSelectedState(): AppCanvasState {
case "pointerhover": {
const nextHitResult = shapeHandler.hitTest(event.data.current, ctx.getScale());
if (shapeHandler.saveHitResult(nextHitResult)) {
boundingHitResult = undefined;
ctx.redraw();
}

if (nextHitResult) {
boundingHitResult = undefined;
return;
}

Expand All @@ -136,6 +139,10 @@ export function newArrowSelectedState(): AppCanvasState {
ctx.redraw();
}

if (hitBounding) {
return;
}

return handleIntransientEvent(ctx, event);
}
case "contextmenu":
Expand Down
13 changes: 3 additions & 10 deletions src/composables/states/appCanvas/arrow/arrowTwoSelectedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { newResizingState } from "../resizingState";
import { newRotatingState } from "../rotatingState";
import { TwoSidedArrowShape } from "../../../../shapes/twoSidedArrow";
import { newArrowTwoHandler } from "../../../shapeHandlers/arrowTwoHandler";
import { findBetterShapeAt } from "../../../shapeComposite";
import { newMovingArrowHeadState } from "./movingArrowHeadState";
import { getPatchByLayouts } from "../../../shapeLayoutHandler";
import { newMovingArrowToState } from "./movingArrowToState";
Expand Down Expand Up @@ -137,18 +136,12 @@ export function newArrowTwoSelectedState(): AppCanvasState {
boundingHitResult = hitBounding;
ctx.redraw();
}
if (boundingHitResult) {
ctx.setCursor();

if (hitBounding) {
return;
}

const shapeAtPointer = findBetterShapeAt(
ctx.getShapeComposite(),
event.data.current,
ctx.getShapeComposite().getSelectionScope(targetShape),
);
ctx.setCursor(shapeAtPointer ? "pointer" : undefined);
return;
return handleIntransientEvent(ctx, event);
}
case "shape-updated": {
if (event.data.keys.has(targetShape.id)) {
Expand Down

0 comments on commit 2620c07

Please sign in to comment.