angular - How to change animation attribute in ionic 3 -
i using slidein animation more 1 components in ionic 3, need change attribute of animation on button can reverse animation of components.
let say: first component slides out towards left , second component slides in right on transfer button click.
i need reverse animation on button click.
code in html:
<div class="adjust" style=" position: relative"> <div class="box" *ngif="!tranfer; else anim" [@slideinanimation] style="position: absolute "> <first></first> </div> <ng-template #anim> <div class="box " [@slideinanimation] style="position: absolute "> <second></second> </div> </ng-template> </div> <button ion-button (click)="show() "> transfer</button> <button ion-button (click)="back() "> back</button>
code in ts file:
@component({ selector: 'page-home', templateurl: 'home.html', animations: [ trigger( 'slideinanimation', [ transition(':enter', [ style({transform: 'translatex(100%)', opacity: 0}), animate('1500ms', style({transform: 'translatex(0)', opacity: 1})) ]), transition(':leave', [ style({transform: 'translatex(0)', opacity: 1}), animate('1500ms', style({transform: 'translatex(-100%)', opacity: 0})) ]) ]), trigger( 'slideoutanimation', [ transition(':enter', [ style({transform: 'translatex(-100%)', opacity: 0}), animate('1500ms', style({transform: 'translatex(0)', opacity: 1})) ]), transition(':leave', [ style({transform: 'translatex(0)', opacity: 1}), animate('1500ms', style({transform: 'translatex(100%)', opacity: 0})) ]) ]) ] }) export class homepage { tranfer: boolean =false; constructor(public navctrl: navcontroller) { } show(){ this.tranfer=true; } back(){ this.tranfer=false; } }
first , second components , want change animation slideinanimation slideoutanimation.
please this.
Comments
Post a Comment