相关疑难解决方法(0)

推迟删除视图,以便对其进行动画处理

假设我有一个显示基于属性的视图的模板:

{{#if App.contentsAreVisible}}
    {{view ToggleContents}}
{{/if}}
Run Code Online (Sandbox Code Playgroud)

通过设置,可以通过UI的任意数量的其他部分切换此区域 App.set("contentsAreVisible", [true/false]);

一切正常.

但是,我现在想要在切换视图时进行动画处理.连接didInsertElement到动画显示区域的工作,但我不能这样做willDestroyElement因为在动画有机会运行之前,该函数返回后立即删除元素.

App.ToggleContents = Ember.View.extend({

    // this works fine
    didInsertElement: function(){
        this.$().hide().show("slow");
    },

    // this doesn't work
    willDestroyElement: function(){
        this.$().hide("slow", function(){
            // animation is complete, notify that the element can be removed
        });
    }
});
Run Code Online (Sandbox Code Playgroud)

有没有办法告诉视图推迟从DOM中删除元素,直到动画完成?

这是一个互动示例的小提琴:http://jsfiddle.net/rlivsey/RxxPU/

javascript jquery ember.js

6
推荐指数
1
解决办法
3383
查看次数

标签 统计

ember.js ×1

javascript ×1

jquery ×1