Skip to main content

Class: FrameService

Constructors​

Constructor​

new FrameService(forceImageCover?, initialZoom?, forceImageContain?): FrameService

Parameters​

forceImageCover?​

boolean

initialZoom?​

number

forceImageContain?​

boolean

Returns​

FrameService

Properties​

maxZoomScale​

maxZoomScale: number[]

The calculated maximum zoom value. Note: This is calculated based on the first frame.


minZoomScale​

minZoomScale: number[]

The calculated minimum zoom value, per frame.

Methods​

connectWorkflowManager()​

connectWorkflowManager(workflowManager, stepName?): void

When we want to connect a workflow manager to the state of the image cropper we can pass it to this function. Inside we'll attach any required event listeners.

Parameters​

workflowManager​

WorkflowManager

The workflow manager to attach.

stepName?​

string

The specific step we want to attach to within the manager.

Returns​

void


getFrameData()​

getFrameData(): FrameData[] | undefined

Gets the current calculated frame data

Returns​

FrameData[] | undefined

A FrameData object or undefined if no frame has been set.


getImageData()​

getImageData(): PatternImageData | undefined

Gets the currently set image of the frame..

Returns​

PatternImageData | undefined

A PatternImageData object, or undefined if no image is set.


getImageSrc()​

getImageSrc(): string | undefined

Helper function to get the src of the image of the frame, since it can be an svg with modified colors.

Returns​

string | undefined

A url (a data url if svg), or undefined if no image is set.


getOffsets()​

getOffsets(): FrameOffsets[] | undefined

Gets the current calculated offsets of the pattern within the frame.

Returns​

FrameOffsets[] | undefined

A FrameOffsets object or undefined if no offsets are defined.


getThresholdSettings()​

getThresholdSettings(): FrameThresholdSettings

Returns​

FrameThresholdSettings


onFrameDataChanged()​

onFrameDataChanged(newListener): void

Parameters​

newListener​

(frameData) => void

Returns​

void


onRotation()​

onRotation(newListener): void

Append a new listener to rotation events on this frame.

Parameters​

newListener​

(rotationValue) => void

Returns​

void


onZoom()​

onZoom(newListener): void

Append a new listener to zoom events on this frame.

Parameters​

newListener​

(zoomValue) => void

Returns​

void


setFrameData()​

setFrameData(paths): void

Sets the current frame data. Note:

Parameters​

paths​

string[] | undefined

The paths to lookup in our frame data cache.

Returns​

void


setOffsets()​

setOffsets(offsets): void

Updates the frame offsets explicitly.

Parameters​

offsets​

FrameOffsets[]

Returns​

void


setPatternData()​

setPatternData(value, recalculateOffsets?): void

Sets the image currently contained by this frame.

Parameters​

value​

PatternImageData

The new image as an ImageData property

recalculateOffsets?​

boolean = true

Optional: Enable/disable re-calculating of frame offsets. Default: true. Note: Will always calculate when offsets have not been calculated.

Returns​

void


setRotation()​

setRotation(rotation, onComplete?): void

Sets the rotation of the pattern within the frame

Parameters​

rotation​

number[]

The new rotation value in degrees, per frame

onComplete?​

() => void

A function to call when rotation changes have been completed

Returns​

void


setTargetElements()​

setTargetElements(targetElements): void

Sets the elements that should be update when changes are made to the cropper that owns this service.

Parameters​

targetElements​

string[]

A list of element Ids to track

Returns​

void


setThresholdSettings()​

setThresholdSettings(settings): void

Parameters​

settings​

FrameThresholdSettings

Returns​

void


setZoom()​

setZoom(zoom, cX, cY, onComplete?): void

Sets the zoom of the cropper that owns this service.

Parameters​

zoom​

number[]

The new zoom value, per frame.

cX​

number[]

The center of zoom on x axis, per frame.

cY​

number[]

The center of zoom on Y axis, per frame.

onComplete?​

() => void

A function to call when zoom changes have been completed

Returns​

void


updateOffsets()​

updateOffsets(value, onComplete?, forceUpdate?): void

Modify the offsets of the frame.

Parameters​

value​

FrameOffsets[]

The new FrameOffsets objects.

onComplete?​

() => void

A callback, called when the modification is complete

forceUpdate?​

boolean

When true the offsets will be updated even if they haven't changed.

Returns​

void