From 0031310ea80a33b1752d3813070b00215f0c52c6 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Mon, 27 Feb 2012 21:55:37 -0800 Subject: Timeline: Successfully unbind event listeners in tweens when clearing timeline. --- .../Timeline/TimelinePanel.reel/TimelinePanel.js | 6 +----- .../Timeline/TimelineTrack.reel/TimelineTrack.html | 5 +++++ js/panels/Timeline/Tween.reel/Tween.js | 19 +++++++++++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) (limited to 'js') diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 912dce83..69e6527f 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -277,8 +277,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { // Remove every event listener for every tween in TimelineTrack for (var i = 0; i < this.arrTracks.length; i++) { for (var j = 0; j < this.arrTracks[i].tweens.length; j++) { - //this.eventManager.removeEventListener("elementChange", this, false); - this.arrTracks[i].tweens[j].eventManager.removeEventListener("elementChange", this.arrTracks[i].tweens[j], false); + this.arrTracks[i].tweens[j].isClearing = "clear it"; } } @@ -539,8 +538,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { if(this._openDoc){ event.detail.ele.uuid =nj.generateRandom(); - console.log("in open doc") - console.log(event.detail.ele) thingToPush.elementsList.push(event.detail.ele); } @@ -696,7 +693,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { handleElementAdded:{ value:function (event) { - console.log('called') event.detail.uuid=nj.generateRandom(); this.hashElementMapToLayer.setItem(event.detail.uuid, event.detail,this.currentLayerSelected); this.currentLayerSelected.elementsList.push(event.detail); diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.html b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.html index 158d666e..26d045d6 100644 --- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.html +++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.html @@ -62,6 +62,11 @@ "boundObject" : {"@": "tweenRepetition"}, "boundObjectPropertyPath" : "objectAtCurrentIteration.isTweenAnimated", "oneway" : false + }, + "isClearing" : { + "boundObject" : {"@": "tweenRepetition"}, + "boundObjectPropertyPath" : "objectAtCurrentIteration.isClearing", + "oneway" : false } } }, diff --git a/js/panels/Timeline/Tween.reel/Tween.js b/js/panels/Timeline/Tween.reel/Tween.js index a9ee1fec..729abd64 100644 --- a/js/panels/Timeline/Tween.reel/Tween.js +++ b/js/panels/Timeline/Tween.reel/Tween.js @@ -118,6 +118,21 @@ var Tween = exports.Tween = Montage.create(Component, { this.needsDraw = true; } }, + + _isClearing : { + serializable: true, + value: false + }, + isClearing : { + get: function() { + return this._isClearing; + }, + set: function(newVal) { + if (newVal === "clear it") { + this.eventManager.removeEventListener("elementChange", this, false); + } + } + }, prepareForDraw:{ value:function () { @@ -141,9 +156,6 @@ var Tween = exports.Tween = Montage.create(Component, { if (event.detail.source && event.detail.source !== "tween") { // check for correct element selection - console.log("handleElementChange! " + this.tweenID) - console.log(this.application.ninja.selectedElements[0]._element); - console.log(this.parentComponent.parentComponent.animatedElement); if (this.application.ninja.selectedElements[0]._element != this.parentComponent.parentComponent.animatedElement) { alert("Wrong element selected for this keyframe track"); } else { @@ -165,7 +177,6 @@ var Tween = exports.Tween = Montage.create(Component, { selectTween:{ value: function(){ // turn on event listener for element change - console.log('adding elementChange event listener for tween ' + this.tweenID) this.eventManager.addEventListener("elementChange", this, false); // select the containing layer -- cgit v1.2.3