I'm trying to set default position to cropper. This is what I have:
ngAfterViewInit(): void {
const image = this.imageElement.nativeElement as HTMLImageElement;
image.onload = () => {
this.cropper = new Cropper(image, {
checkCrossOrigin: true,
checkOrientation: true,
dragMode: 'none',
zoomable: false,
background: false,
data: {
width: 240,
height: 130
}
});
};
}
I tried adding setCropBoxData like this:
ngAfterViewInit(): void {
const image = this.imageElement.nativeElement as HTMLImageElement;
image.onload = () => {
this.cropper = new Cropper(image, {
checkCrossOrigin: true,
checkOrientation: true,
dragMode: 'none',
zoomable: false,
background: false,
data: {
width: 240,
height: 130
}
});
this.cropper.setCropBoxData({
left: 100,
right: 100
})
};
}
But it's not working. I also tried using setData() method. Also not working.
Found solution:
ngAfterViewInit(): void {
const image = this.imageElement.nativeElement as HTMLImageElement;
image.onload = () => {
this.cropper = new Cropper(image, {
checkCrossOrigin: true,
checkOrientation: true,
dragMode: 'none',
zoomable: false,
background: false,
data: {
width: 240,
height: 130,
x: value,
y: value
}
});
};
}
Added x,y properties in data object.