输入动画不在 Angular 中播放 [英] Enter animation not playing in Angular
问题描述
我想知道如何在 angular 应用程序启动时为元素设置动画.
I'm wondering how could I animate an element when the angular app is starting.
确实,我看到(我可能做错了什么)动画模块第一次没有触发输入"事件,但在一切正常之后.如何在不重写动画模块中的所有代码的情况下为其设置动画?
Indeed, I see (I'm maybe doing something wrong) that the animation module is not triggering the "enter" event the first time, but after everything goes fine. How could I animate it without rewriting all the code I have in my animation module somewhere else ?
你可以在我的 fiddle 上看到,li 乍一看是绿色的,当我需要它是我输入动画中定义的蓝色.
You can see on my fiddle that the li is green at first glance, when I need it to be blue as defined in my enter animation.
我不知道它是否只出现在我的配置中,如下所示:
I don't know if it only occurs in my configuration which is the following :
<li ng-if="$index === value" ng-repeat="proj in projects" class="test-anim">test</li>
,动画测试动画类.
感谢您的回答
推荐答案
这是在 1.2.3 中设计的.看到这个问题:
This is by design in 1.2.3. See this issue:
https://github.com/angular/angular.js/issues/5130
您可以使用像这样的超时来尝试等到页面呈现后再向您的 ng-repeat/ng-if 添加数据:
You could use a timeout like this to try to wait until the page is rendered before adding data to your ng-repeats/ng-if:
$timeout(function(){
$scope.value = 0;
$scope.projects = [{}, {}, {}];
}, 0);
这篇关于输入动画不在 Angular 中播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!