我有一个带有一点动画类的应用程序.动画类创建一个画布(使用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之前完成动画时,是否足以调用?
我一般不确定如何确保一切都是垃圾收集,所以欢迎任何建议!
我无法得到directiv i angular to bind on mouseenter,我试过一个简单的例子,这里有什么问题?
<html lang="en" >
<head>
<title>My AngularJS test</title>
<script src="angular.js"></script>
</head>
<body >
<div ng-app="testApp" ng-controller="testCtr">
<div testDir>test here</div>
<!-- just testing to see if the app is working -->
{{test}}
<script type="text/javascript">
var app = angular.module("testApp", []);
app.directive("testDir", function(){
return {
link: function(scope, element, attrs){
element.bind("mouseenter", function(){
console.log("enter")
})
}
}
})
app.controller("testCtr", function($scope) {
$scope.test = 500;
})
</script>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这可能是一个愚蠢的错误,但我看不到它.