角度的动画不是动画
发布时间:2020-12-17 17:33:51 所属栏目:安全 来源:网络整理
导读:我想在Angular4项目中使用animejs. 我一直在寻找一些提示和线索如何继续这个,但几乎没有任何地方. 所以我试图沿x坐标移动框… animejs-logo.component.ts文件: import { Component,OnInit } from '@angular/core';import anime from 'animejs';@Component({
我想在Angular4项目中使用animejs.
我一直在寻找一些提示和线索如何继续这个,但几乎没有任何地方. 所以我试图沿x坐标移动框… animejs-logo.component.ts文件: import { Component,OnInit } from '@angular/core'; import anime from 'animejs'; @Component({ selector: 'app-animejs-logo',templateUrl: './animejs-logo.component.html',styleUrls: ['./animejs-logo.component.scss'] }) export class AnimejsLogoComponent { animation = anime({ targets: ['.box'],translateX: [ { value: 500,duration: 1000 },{ value: 0,duration: 1000 } ],duration: 2000,loop: true }); animate() { console.log('play'); this.animation.play(); } } animejs-logo.component.scss: .box { position: relative; width: 50px; height: 50px; margin: 4px; } .red { background-color: #f00; } .green { background-color: #0f0; } .blue { background-color: #00f; } animejs-logo.component.html: <div class="container"> <button (click)="animate()">Play</button> <div class="box red"></div> <div class="box green"></div> <div class="box blue"></div> </div> 如你所见,没有什么特别或令人难以置信的.首先试试animejs …… 解决方法
好的,解决了.
问题是我在生命周期的错误时刻定义了动漫对象…… ngAfterViewInit() { this.square = anime({ targets: '#animation_1 .animate',translateX: [ { value: 250,duration: 1000 } ],loop: false,autoplay: false }); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |