chenqingspring / ng-lottie

Render After Effects animations on Angular based on lottie-web
MIT License
340 stars 100 forks source link

animation #14

Closed MELAS007 closed 7 years ago

MELAS007 commented 7 years ago

Dear,

I would like to know if you could help me to know how can I appear disappear the animation when i click on like button in ionic 3?

thanks in advance!

mkgrow commented 7 years ago

When you click button show or hide element, you can do like this:

import {Component} from '@angular/core';

@Component({
     template: ` <div  *ngIf = "isShow"></div>
                      <button (click)="isShow()">show or hide</button>`
})

export class TestComponent {
     private isShow = true;
     constructor() {}

     isShow() {
         this.isShow = !this.isShow;
     }
}
MELAS007 commented 7 years ago

Thank you so much for your help! It is not a

but <lottie-animation-view [options]="lottieConfig" [width]="300" [height]="200" (animCreated)="handleAnimation($event)">

@makan020518

mkgrow commented 7 years ago

You can use *ngIf directly

import {Component} from '@angular/core';

@Component({
     template: ` <lottie-animation-view  *ngIf="isShow"></lottie-animation-view>
                        <button (click)="isShow()">show or hide</button>`
})

export class TestPage {
     private isShow = true;
     constructor() {}

     isShow() {
         this.isShow = !this.isShow;
     }
}

@MELAS007

chenqingspring commented 7 years ago

Thanks for your help! @makan020518

@MELAS007 You can also use *ngIf out of lottie-animation-view, and handle the toggle logic in your own component, like the first example makan020518 provided :-)

MELAS007 commented 7 years ago

@makan020518 Thank you Very much !