I am using cropper.js to crop an image in my angular project. In this the cropped part will be highlighted with a div when it is cropped. Here I am binding the crop box values into the div. But when I resize the window, this div is not adjusting in respect to it's cropped part. How do I fix this?
<div
class="overlay"
*ngFor="let crop of croppedImages"
[style.width]="getWidth(crop.width) + '%' "
[style.height]="getHeight(crop.height) + '%' "
[style.left.px]="crop.x"
[style.top.px]="crop.y"
></div>
//style
.overlay{
background-color: grey;
position: absolute;
}
getWidth(width: number){
let screenWidth = window.innerWidth;
width = (width/screenWidth) * 100;
return width;
}
getHeight(height: number){
let screenHeight = window.innerHeight;
height = ((height/screenHeight) * 100);
return height;
}