angular - Why are CSS transformations on the same image interfering with one another? -


i'm new angular, apologies may dim question.

i have 2 buttons click events: 1 modifying scale of image, , 1 rotating same image.

triggering scale change overrides rotation, , vice versa.

example

  1. i click rotate button, , image tilts.
  2. then click scale button, , image reduces in scale, loses tilt.

html

<button (click)="togglescale()" type="button" class="btn btn-outline-primary">scale</button> <button (click)="togglerotation()" type="button" class="btn btn-outline-primary">rotate</button>  <img class="mainimg"  src="./public/img/placeholder.png"       [@scale] = 'scale' [@rotation] = 'rotation' /> 

animations

animations: [   trigger('scale', [     state('fullscale', style({       transform: 'scale(1)'     })),     state('halfscale', style({       transform: 'scale(0.5)'     })),     transition('fullscale => halfscale', animate('100ms ease-in')),     transition('halfscale => fullscale', animate('100ms ease-out')),   ]),   trigger('rotation', [     state('defaultrotation', style({       transform: 'rotate(0deg)'     })),     state('newrotation', style({       transform: 'rotate(45deg)'     })),     transition('defaultrotation => newrotation', animate('100ms ease-in')),     transition('newrotation => defaultrotation', animate('100ms ease-out')),   ]) ] 

component

export class appcomponent  {     scale    = 'fullscale';   rotation = 'defaultrotation';    togglescale() {     this.scale = (this.scale == 'fullscale' ? 'halfscale' : 'fullscale');   }    togglerotation() {     this.rotation = (this.rotation == 'defaultrotation' ? 'newrotation' : 'defaultrotation');   } } 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -