Øyv*_*ind 6 javascript performance easeljs createjs
我有一个带有一点动画类的应用程序.动画类创建一个画布(使用jQuery),创建一个createjs.Stage使用此画布的元素,然后使用此舞台元素在短时间内完成一些动画.
动画完成后,我想清理所有内容,以便新动画可以做同样的事情.
使用Stage类时,例如createjs.Ticker.addEventListener(stage),需要添加一些侦听器,并且可能需要添加DOMEventlistener.
我试图弄清楚如何安全地删除舞台和画布,到目前为止,我已经找到一些信息,说明stage.canvas = null在将舞台设置为null之前必须将舞台画布设置为null()
我还在舞台上找到了一个方法:
.removeAllEventListeners()
Run Code Online (Sandbox Code Playgroud)
所以这是我的问题:
如果画布和舞台仅添加到动画类中,那么就这样做就足够了:
var animation = new Animation();
// do some stuff, call some methods on the animation object, and then:
animation = null;
Run Code Online (Sandbox Code Playgroud)
我想你必须手动从画面上移除画布jQuery.remove()或者去掉画布.
如果上述方法不正确,那么.removeAllEventListeners()在将舞台设置为null之前完成动画时,是否足以调用?
我一般不确定如何确保一切都是垃圾收集,所以欢迎任何建议!
| 归档时间: |
|
| 查看次数: |
1329 次 |
| 最近记录: |