嗨,有没有办法使用纯 CSS 在组件/元素移除时使用淡出?目前删除发生得如此之快,最终用户很难看到实际发生了什么。
例如,我有这个淡入代码。它很容易添加,您不需要更改任何脚本逻辑。
{{#each dataContainer as |data|}}
<div class="panel custom-panel fade-in">
xx
<button class="remove" {{action "Remove"}}> Delete </button>
</div>
{{/each}}
.fade-in{
animation: fadeIn 1s;
}
@keyframes fadeIn {
from {
background-color: #fff7c0;
opacity:0;
}
to {
background-color: white;
opacity:1;
}
}
理想情况下会这样写
{{#each items as |item|}}
{{#fade-component}}
{{content-component}}
{{/fade-component}}
{{/each}}
而淡入淡出-c 会有
willAnimateIn : function () {
this.$().css("opacity", 0);
},
animateIn : function (done) {
this.$().fadeTo(500, 1, done);
},
animateOut : function (done) {
this.$().fadeTo(500, 0, done);
}
我自己尝试的方式(正是我想忽略的东西,更改删除代码)
$('.remove.btn').click(function() {
$(this).closest('.fade-in').addClass('fade-out')
});
removeRecord: function(wrappedRecord) {
Ember.run.later((function() {
xx
}), 500);
}