This will work for you if you want to use it only with a transition .!
.syncRotate { -webkit-transition: 500ms ease all; -moz-transition: 500ms ease all; -o-transition: 500ms ease all; transition: 500ms ease all; -webkit-transform: rotate(0deg); } .syncRotate:active { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
<button class="iconBtn" mdTooltipPosition="above" mdTooltip="Sync User" (click)="sync()"> <img class="syncRotate" style="width:20px;background-color: #a6a6a6;border-radius: 13px;padding:2px;" src="https://lh6.ggpht.com/bE_u2kFoX28G428YH1jpWTMoaZ3B9cokstrKxD82zj7hoBNL-U1wiAVddau3mvvUpPoD=w300" alt="Sync"> </button>
IF you want to make nice animations using CSS animations
@keyframes rotation { 0% { -webkit-transform: rotate(0deg); } 50% { -webkit-transform: rotate(360deg); } 100% { -webkit-transform: rotate(0deg); } } .syncRotate { -webkit-transform: rotate(0deg); } .syncRotate:active { animation: rotation 500ms ease-in-out forwards; }
<button class="iconBtn" mdTooltipPosition="above" mdTooltip="Sync User" (click)="sync()"> <img class="syncRotate" style="width:20px;background-color: #a6a6a6;border-radius: 13px;padding:2px;" src="https://lh6.ggpht.com/bE_u2kFoX28G428YH1jpWTMoaZ3B9cokstrKxD82zj7hoBNL-U1wiAVddau3mvvUpPoD=w300" alt="Sync"> </button>
Changing from 500 ms to 400 ms, we can speed it up , and changing it higher will make the animation and transition slower, for example, 900 ms or 1 s .
Note. . Since we are only using CSS , animations and transitions are performed only when the button is clicked. SO in your case both will be the same.
source share