RectangleStencil

A rectangle crop region registered through its ancestor cropper context.

<script lang="ts">
	import { Cropper, RectangleStencil } from 'svelte-advanced-cropper';
</script>

<Cropper src="/photo.jpg" style="height: 360px">
	<RectangleStencil grid />
</Cropper>

Props

All optional props without a default remain undefined. class accepts Svelte ClassValue; style is a CSS string.

PropTypeDefault
childrenSnippetundefined
coordinatesCoordinates | ((state: CropperState | null) => Coordinates)undefined
handlerSnippet<[HandlerSnippetProps]>SimpleHandler
handlersboolean | Partial<Record<OrdinalDirection, boolean>>All eight directions
linesboolean | Partial<Record<CardinalDirection, boolean>>All four cardinal directions
lineSnippet<[LineSnippetProps]>SimpleLine
classClassValueundefined
stylestringundefined
minAspectRationumberundefined
maxAspectRationumberundefined
aspectRatioRawAspectRatioundefined
movablebooleantrue
resizablebooleantrue
gridbooleanundefined
disabledbooleanundefined

Omitted grid and local disabled are falsy. The effective disabled value also includes the cropper’s disabled state. resizable={false} disables controls; handlers={false} and lines={false} hide them. A direction map shows only entries whose value is true; true enables every direction.

coordinates controls display coordinates in boundary pixels. Without it, the stencil reads getStencilCoordinates(). It does not replace crop state. The optional grid appears during interactions, with nine divisions while rotating and three otherwise.

Snippets and context

handler: Snippet<[HandlerSnippetProps]> and line: Snippet<[LineSnippetProps]> replace interactive controls. Forward the supplied positioning class and original native event. children: Snippet renders inside the draggable crop region above the overlay.

Requires CropperContext and registers during initialization. There are no imperative component methods and no nested context provider.

Rectangle options are computed from aspectRatio, minAspectRatio and maxAspectRatio. An explicit cropper aspect ratio wins under the default constraint strategy.

Selectors

.advanced-cropper-rectangle-stencil owns --movable, --moving, --resizable, --resizing, --disabled, __bounding-box, __draggable-area, __overlay, __preview and __grid. See expanded selectors.