http://codepen.io/jdoyle/pen/aJoVJj
据我所知道的,不透明的CSS属性会对对象没有影响因为这个原因,我认为你不能使用.ng-leave
。动画不透明度的唯一方法是通过动画组件或编程方式。
使用$timeout
提供程序,并知道动画持续时间,你可以设置一些事情g up像这样:
<a-box ng-repeat="box in page.getActiveBoxes() track by box.id"
ng-class="{animated: page.animate}"
position="{{box.position}}"
rotation="0 45 0"
width="0.6" height="1" depth="0.6"
color="{{box.color}}"
>
<a-animation attribute="opacity" begin="fadeOut" duration="5000" to="0"></a-animation>
</a-box>
fadeOut() {
var id = this.getRandomInt(0, this.boxes.length-1);
document.querySelector('#box-' + id).emit('fadeOut');
this.$timeout(function() {
// you can now delete the primitive
}, 5000 + 50); // added 50ms for good measure
}
getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
这不是最优雅的解决方案,但我真的不能想到另一种方式。
另一个令人失望的情况是角度插值不适用于动画的持续时间属性。持续时间一旦设定,不能改变。这是行不通的:
<a-animation attribute="opacity" duration="{{page.animationDuration}}" begin="fadeOut" to="0"></a-animation>
你能够在Codepen中创建一个演示,例如默认场景:http://codepen.io/mozvr/pen/BjygdO? –
@JoelCDoyle是的,看看这个codePen:http://codepen.io/Disorrder/pen/BWBKpb – Disorder