Skip to content

Commit f88a594

Browse files
committed
refactor: use getHandleDirections util
1 parent 52fb1f7 commit f88a594

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

packages/machines/image-cropper/src/image-cropper.connect.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as dom from "./image-cropper.dom"
44
import type { FlipState, ImageCropperApi, ImageCropperService } from "./image-cropper.types"
55
import { getEventPoint, contains, getEventKey, dataAttr } from "@zag-js/dom-query"
66
import { toPx } from "@zag-js/utils"
7+
import { getHandleDirections } from "./image-cropper.utils"
78

89
const getRoundedCrop = (crop: Rect) => ({
910
x: Math.round(crop.x),
@@ -66,10 +67,7 @@ export function connect<T extends PropTypes>(
6667
if (!handlePosition) return
6768
if (prop("fixedCropArea")) return
6869

69-
const hasLeft = handlePosition.includes("left")
70-
const hasRight = handlePosition.includes("right")
71-
const hasTop = handlePosition.includes("top")
72-
const hasBottom = handlePosition.includes("bottom")
70+
const { hasLeft, hasRight, hasTop, hasBottom } = getHandleDirections(handlePosition)
7371

7472
let deltaX = 0
7573
let deltaY = 0

packages/machines/image-cropper/src/image-cropper.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ interface ClampAspectParams {
3636
aspectRatio: number
3737
}
3838

39-
const getHandleDirections = (handlePosition: HandlePosition): HandleDirections => ({
39+
export const getHandleDirections = (handlePosition: HandlePosition): HandleDirections => ({
4040
hasLeft: handlePosition.includes("left"),
4141
hasRight: handlePosition.includes("right"),
4242
hasTop: handlePosition.includes("top"),

0 commit comments

Comments
 (0)