aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Reid2012-02-27 21:55:37 -0800
committerJon Reid2012-02-27 21:55:37 -0800
commit0031310ea80a33b1752d3813070b00215f0c52c6 (patch)
tree16fbf4c0de9b586ce28d2f6d5901a13636fa1226
parent445180591da04f681a22038600e8ab517b82c0ca (diff)
downloadninja-0031310ea80a33b1752d3813070b00215f0c52c6.tar.gz
Timeline: Successfully unbind event listeners in tweens when clearing timeline.
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js6
-rw-r--r--js/panels/Timeline/TimelineTrack.reel/TimelineTrack.html5
-rw-r--r--js/panels/Timeline/Tween.reel/Tween.js19
3 files changed, 21 insertions, 9 deletions
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, {
277 // Remove every event listener for every tween in TimelineTrack 277 // Remove every event listener for every tween in TimelineTrack
278 for (var i = 0; i < this.arrTracks.length; i++) { 278 for (var i = 0; i < this.arrTracks.length; i++) {
279 for (var j = 0; j < this.arrTracks[i].tweens.length; j++) { 279 for (var j = 0; j < this.arrTracks[i].tweens.length; j++) {
280 //this.eventManager.removeEventListener("elementChange", this, false); 280 this.arrTracks[i].tweens[j].isClearing = "clear it";
281 this.arrTracks[i].tweens[j].eventManager.removeEventListener("elementChange", this.arrTracks[i].tweens[j], false);
282 } 281 }
283 } 282 }
284 283
@@ -539,8 +538,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
539 538
540 if(this._openDoc){ 539 if(this._openDoc){
541 event.detail.ele.uuid =nj.generateRandom(); 540 event.detail.ele.uuid =nj.generateRandom();
542 console.log("in open doc")
543 console.log(event.detail.ele)
544 thingToPush.elementsList.push(event.detail.ele); 541 thingToPush.elementsList.push(event.detail.ele);
545 } 542 }
546 543
@@ -696,7 +693,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
696 693
697 handleElementAdded:{ 694 handleElementAdded:{
698 value:function (event) { 695 value:function (event) {
699 console.log('called')
700 event.detail.uuid=nj.generateRandom(); 696 event.detail.uuid=nj.generateRandom();
701 this.hashElementMapToLayer.setItem(event.detail.uuid, event.detail,this.currentLayerSelected); 697 this.hashElementMapToLayer.setItem(event.detail.uuid, event.detail,this.currentLayerSelected);
702 this.currentLayerSelected.elementsList.push(event.detail); 698 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 @@
62 "boundObject" : {"@": "tweenRepetition"}, 62 "boundObject" : {"@": "tweenRepetition"},
63 "boundObjectPropertyPath" : "objectAtCurrentIteration.isTweenAnimated", 63 "boundObjectPropertyPath" : "objectAtCurrentIteration.isTweenAnimated",
64 "oneway" : false 64 "oneway" : false
65 },
66 "isClearing" : {
67 "boundObject" : {"@": "tweenRepetition"},
68 "boundObjectPropertyPath" : "objectAtCurrentIteration.isClearing",
69 "oneway" : false
65 } 70 }
66 } 71 }
67 }, 72 },
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, {
118 this.needsDraw = true; 118 this.needsDraw = true;
119 } 119 }
120 }, 120 },
121
122 _isClearing : {
123 serializable: true,
124 value: false
125 },
126 isClearing : {
127 get: function() {
128 return this._isClearing;
129 },
130 set: function(newVal) {
131 if (newVal === "clear it") {
132 this.eventManager.removeEventListener("elementChange", this, false);
133 }
134 }
135 },
121 136
122 prepareForDraw:{ 137 prepareForDraw:{
123 value:function () { 138 value:function () {
@@ -141,9 +156,6 @@ var Tween = exports.Tween = Montage.create(Component, {
141 156
142 if (event.detail.source && event.detail.source !== "tween") { 157 if (event.detail.source && event.detail.source !== "tween") {
143 // check for correct element selection 158 // check for correct element selection
144 console.log("handleElementChange! " + this.tweenID)
145 console.log(this.application.ninja.selectedElements[0]._element);
146 console.log(this.parentComponent.parentComponent.animatedElement);
147 if (this.application.ninja.selectedElements[0]._element != this.parentComponent.parentComponent.animatedElement) { 159 if (this.application.ninja.selectedElements[0]._element != this.parentComponent.parentComponent.animatedElement) {
148 alert("Wrong element selected for this keyframe track"); 160 alert("Wrong element selected for this keyframe track");
149 } else { 161 } else {
@@ -165,7 +177,6 @@ var Tween = exports.Tween = Montage.create(Component, {
165 selectTween:{ 177 selectTween:{
166 value: function(){ 178 value: function(){
167 // turn on event listener for element change 179 // turn on event listener for element change
168 console.log('adding elementChange event listener for tween ' + this.tweenID)
169 this.eventManager.addEventListener("elementChange", this, false); 180 this.eventManager.addEventListener("elementChange", this, false);
170 181
171 // select the containing layer 182 // select the containing layer