@mocanvas/mocanvas · function
declare function getCropBox<T extends ShapeWithCrop>(shape: T, info: TLCropInfo<T>, options?: CropBoxOptions): Partial<T> | undefinedThe shape update one step of a crop drag produces, or undefined when the
drag would change nothing.
Returns a partial in the same form onResize does — x, y and the
changed props — so a util's onCrop can hand it straight back:
``ts
override onCrop(shape: ImageShape, info: TLCropInfo<ImageShape>) {
return getCropBox(shape, info, { minWidth: 32 })
}
``
The handle being dragged decides which of the four normalized edges moves.
Each edge is clamped so the window stays inside 0…1 and so the box stays
above the minimum; because every step recomputes from info.initialShape
rather than from the shape's current state, a drag that hits a clamp and
comes back lands exactly where it would have without the clamp.
mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.