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