Guest User

Untitled

a guest
Jan 16th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. paso 1
  2. npm install --save lottie-angular2
  3. paso 2
  4. importar en app.module.ts
  5. import { LottieAnimationViewModule } from "lottie-angular2";
  6. paso 3
  7. usar en el import:[....
  8. LottieAnimationViewModule.forRoot()
  9.  
  10. =====
  11. home.html
  12. =====
  13. <ion-header>
  14. <ion-navbar>
  15. <ion-title>
  16. Bienvenido!
  17. </ion-title>
  18. </ion-navbar>
  19. </ion-header>
  20.  
  21.  
  22.  
  23.  
  24. <lottie-animation-view
  25. [options]="lottieConfig"
  26. [width]="300"
  27. [height]="600"
  28. (animCreated)="handleAnimation($event)">
  29. </lottie-animation-view>
  30. <div id="player">
  31. <p>Speed: x{{animationSpeed}}</p>
  32. <div class="range-container">
  33. <input #range type="range" value="1" min="0" max="3" step="0.5"
  34. (change)="setSpeed(range.value)">
  35. </div>
  36. <button ion-button (click)="stop()">stop</button>
  37. <button ion-button (click)="pause()">pause</button>
  38. <button ion-button (click)="play()">play</button>
  39. </div>
  40. =====================
  41. fin home.html
  42. ====================
  43.  
  44.  
  45. =======
  46. home.ts
  47. ======
  48. import { Component } from '@angular/core';
  49. import { NavController } from 'ionic-angular';
  50. import { UsuarioProvider, Credenciales } from '../../providers/usuario/usuario';
  51.  
  52.  
  53. import { LoginPage } from '../login/login';
  54.  
  55. @Component({
  56. selector: 'page-home',
  57. templateUrl: 'home.html'
  58. })
  59. export class HomePage {
  60.  
  61. user: Credenciales = {};
  62. public lottieConfig : Object;
  63. private anim: any;
  64. private animationSpeed: number = 1;
  65.  
  66. constructor(public navCtrl: NavController,
  67. public usuarioProv: UsuarioProvider) {
  68.  
  69. this.lottieConfig={
  70. path:'../assets/soda_loader.json',
  71. renderer: 'canvas',
  72. autoplay:true,
  73. loop:true
  74. };
  75. }
  76.  
  77. handleAnimation(anim: any) {
  78. this.anim = anim;
  79. }
  80.  
  81. stop() {
  82. this.anim.stop();
  83. }
  84.  
  85. play() {
  86. this.anim.play();
  87. }
  88.  
  89. pause() {
  90. this.anim.pause();
  91. }
  92.  
  93. setSpeed(speed: number) {
  94. this.animationSpeed = speed;
  95. this.anim.setSpeed(speed);
  96. }
  97.  
  98. }
Add Comment
Please, Sign In to add comment