javascript - Angular 动画: can't find query

标签 javascript angular animation

我正在学习 Angular 动画,当我单击前 100 个标签并加载页面时,我想使用交错淡入列表项。不幸的是,它说找不到我输入的查询。有人能看到我做错了什么吗?

enter image description here

我的组件中有以下动画代码:

@Component({
    selector: 'app-top100',
    templateUrl: './top100.component.html',
    styleUrls: ['./top100.component.css'],
    animations: [
        trigger('topListAnimation', [
            transition(':enter', [
                query('.list-group-item', [
                    stagger(200, useAnimation(fadeInAnimation))
                ])
            ])
        ])
    ]
})

模板文件

<div @topListAnimation>
    <div class="col-md-8 col-md-offset-2 listDiv">
        <div class="list-group">
            <a
                    [routerLink]="['/movies', movie?._id]"
                    href="#"
                    *ngFor="let movie of movies;
                let i = index"
                    [attr.data-index]="i"
                    class="list-group-item"
            >
                <h3>{{ i+ 1 }}</h3>
                <h3>{{movie?.title}}</h3>
                <span class="glyphicon glyphicon-star"></span>
                <span><h3>{{movie?.averageRating}}</h3></span>
            </a>
        </div>
    </div>
</div>

最佳答案

在模板中设置动画,如下所示 [@topListAnimation]

淡出动画示例

export const FADE_OUT_TRANSITION = [
  trigger('fadeOut',  [
    transition(':leave', animate(700, keyframes([
      style({opacity: 1, offset: 0}),
      style({opacity: 0, offset: 1})
    ])))
  ])
];

我将它导入到我的 Controller 中,就像这样

@Component({
  selector: 'lyx-ghost',
  template: '<div [@fadeOut]>Ghost Busters</div>',
  animations: [...FADE_OUT_TRANSITION]
})
export class GhostComponent {
}

要获得更酷的效果,请查看 animate.css

关于javascript - Angular 动画: can't find query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49035979/

相关文章:

iOS - 使用我的应用程序用户界面在应用程序中嵌入视频

javascript - 如何在以 60 fps 刷新率的同时放慢动画速度?

javascript - 将元素更改为文本区域不起作用

angular - Universal SSR 如何处理 *ngIf 中的异步管道

css - 如何自定义 Angular Material Form Field 组件?

python - 在Python中动画射弹的路径

javascript - TweenLite 动画无法正常工作

Javascript -- 将窗口高度增加一个像素 -- Google Chrome

javascript - 如何在javascript中创建别名

javascript - 带 Angular 动态 iframe 源