I am trying to achieve a rotating effect on a rectangular image within a frame of the same dimensions, as shown below:
<div style="border:1px solid #d3d3d3;width:208px;height:250px">
<img style="width:208px;height:250px" src="https://www.webslake.com/w_img/t_i/lpw.png" [style.transform]="styles"> </div>
<button type="button" class="btn btn-undo btn-lg" (click)="rotateImage('left')">
Here is the function that controls the rotation:
rotateImage(direction) {
if (direction === 'left') {
this.rotationAmount = this.rotationAmount + -90;
} else if(direction === 'right') {
this.rotationAmount = this.rotationAmount + 90;
}
this.styles = 'rotate(' + this.rotationAmount + 'deg)';
}
I am looking for a way to rotate the image inside the frame without altering its width and height. I want to maintain the same dimensions throughout the rotation process, where the new width corresponds to the old height and vice versa.