Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- paso 1
- npm install --save lottie-angular2
- paso 2
- importar en app.module.ts
- import { LottieAnimationViewModule } from "lottie-angular2";
- paso 3
- usar en el import:[....
- LottieAnimationViewModule.forRoot()
- =====
- home.html
- =====
- <ion-header>
- <ion-navbar>
- <ion-title>
- Bienvenido!
- </ion-title>
- </ion-navbar>
- </ion-header>
- <lottie-animation-view
- [options]="lottieConfig"
- [width]="300"
- [height]="600"
- (animCreated)="handleAnimation($event)">
- </lottie-animation-view>
- <div id="player">
- <p>Speed: x{{animationSpeed}}</p>
- <div class="range-container">
- <input #range type="range" value="1" min="0" max="3" step="0.5"
- (change)="setSpeed(range.value)">
- </div>
- <button ion-button (click)="stop()">stop</button>
- <button ion-button (click)="pause()">pause</button>
- <button ion-button (click)="play()">play</button>
- </div>
- =====================
- fin home.html
- ====================
- =======
- home.ts
- ======
- import { Component } from '@angular/core';
- import { NavController } from 'ionic-angular';
- import { UsuarioProvider, Credenciales } from '../../providers/usuario/usuario';
- import { LoginPage } from '../login/login';
- @Component({
- selector: 'page-home',
- templateUrl: 'home.html'
- })
- export class HomePage {
- user: Credenciales = {};
- public lottieConfig : Object;
- private anim: any;
- private animationSpeed: number = 1;
- constructor(public navCtrl: NavController,
- public usuarioProv: UsuarioProvider) {
- this.lottieConfig={
- path:'../assets/soda_loader.json',
- renderer: 'canvas',
- autoplay:true,
- loop:true
- };
- }
- handleAnimation(anim: any) {
- this.anim = anim;
- }
- stop() {
- this.anim.stop();
- }
- play() {
- this.anim.play();
- }
- pause() {
- this.anim.pause();
- }
- setSpeed(speed: number) {
- this.animationSpeed = speed;
- this.anim.setSpeed(speed);
- }
- }
Add Comment
Please, Sign In to add comment