aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/Tween.reel/Tween.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Timeline/Tween.reel/Tween.js')
-rw-r--r--js/panels/Timeline/Tween.reel/Tween.js53
1 files changed, 39 insertions, 14 deletions
diff --git a/js/panels/Timeline/Tween.reel/Tween.js b/js/panels/Timeline/Tween.reel/Tween.js
index 7339139f..7dcd397c 100644
--- a/js/panels/Timeline/Tween.reel/Tween.js
+++ b/js/panels/Timeline/Tween.reel/Tween.js
@@ -6,7 +6,6 @@
6 6
7var Montage = require("montage/core/core").Montage; 7var Montage = require("montage/core/core").Montage;
8var Component = require("montage/ui/component").Component; 8var Component = require("montage/ui/component").Component;
9var ElementsMediator = require("js/mediators/element-mediator").ElementMediator;
10 9
11var Tween = exports.Tween = Montage.create(Component, { 10var Tween = exports.Tween = Montage.create(Component, {
12 11
@@ -44,6 +43,8 @@ var Tween = exports.Tween = Montage.create(Component, {
44 }, 43 },
45 set: function(value){ 44 set: function(value){
46 this._spanWidth = value; 45 this._spanWidth = value;
46 this.tweenData.spanWidth = value;
47 this.needsDraw=true;
47 } 48 }
48 }, 49 },
49 50
@@ -58,6 +59,8 @@ var Tween = exports.Tween = Montage.create(Component, {
58 }, 59 },
59 set:function (value) { 60 set:function (value) {
60 this._spanPosition = value; 61 this._spanPosition = value;
62 this.tweenData.spanPosition = value;
63 this.needsDraw=true;
61 } 64 }
62 }, 65 },
63 66
@@ -72,6 +75,8 @@ var Tween = exports.Tween = Montage.create(Component, {
72 }, 75 },
73 set:function (value) { 76 set:function (value) {
74 this._keyFramePosition = value; 77 this._keyFramePosition = value;
78 this.tweenData.keyFramePosition = value;
79 this.needsDraw=true;
75 } 80 }
76 }, 81 },
77 82
@@ -133,6 +138,7 @@ var Tween = exports.Tween = Montage.create(Component, {
133 } 138 }
134 }, 139 },
135 140
141
136 draw:{ 142 draw:{
137 value:function () { 143 value:function () {
138 this.element.style.left = this.spanPosition + "px"; 144 this.element.style.left = this.spanPosition + "px";
@@ -159,27 +165,44 @@ var Tween = exports.Tween = Montage.create(Component, {
159 165
160 handleElementChange:{ 166 handleElementChange:{
161 value:function (event) { 167 value:function (event) {
162 168 // temp - testing var
169 var useAbsolute = true;
170
163 if (event.detail.source && event.detail.source !== "tween") { 171 if (event.detail.source && event.detail.source !== "tween") {
164 // check for correct element selection 172 // check for correct element selection
165 if (this.application.ninja.selectedElements[0]!= this.parentComponent.parentComponent.animatedElement) { 173 if (this.application.ninja.selectedElements[0] != this.parentComponent.parentComponent.animatedElement) {
166 console.log("Wrong element selected for this keyframe track"); 174 console.log("Wrong element selected for this keyframe track");
167 } else { 175 } else {
168 // update tweenedProperties and tell containing track to update CSS rule 176 if(useAbsolute){
169 // temp read only top and left. need to change to loop over event details for prop changes generically 177 this.setAbsoluteTweenProperties(event.detail);
170 if (this.parentComponent.parentComponent.animatedElement.offsetTop != this.tweenedProperties["top"] && this.parentComponent.parentComponent.animatedElement.offsetLeft != this.tweenedProperties["left"]) { 178 } else {
171 this.tweenedProperties["top"] = this.parentComponent.parentComponent.animatedElement.offsetTop; 179 this.setRelativeTweenProperties(event.detail);
172 this.tweenedProperties["left"] = this.parentComponent.parentComponent.animatedElement.offsetLeft;
173 this.parentComponent.parentComponent.updateKeyframeRule();
174 } 180 }
175 // highlight the tween's span
176 this.tweenspan.highlightSpan();
177 this.isTweenAnimated = true;
178 } 181 }
179 } 182 }
180 } 183 }
181 }, 184 },
182 185
186 setAbsoluteTweenProperties:{
187 value:function (eventDetail) {
188 //console.log(eventDetail);
189 if (this.parentComponent.parentComponent.animatedElement.offsetTop != this.tweenedProperties["top"] && this.parentComponent.parentComponent.animatedElement.offsetLeft != this.tweenedProperties["left"]) {
190 this.tweenedProperties["top"] = this.parentComponent.parentComponent.animatedElement.offsetTop;
191 this.tweenedProperties["left"] = this.parentComponent.parentComponent.animatedElement.offsetLeft;
192 this.parentComponent.parentComponent.updateKeyframeRule();
193 }
194 // highlight the tween's span
195 this.tweenspan.highlightSpan();
196 this.isTweenAnimated = true;
197 }
198 },
199
200 setRelativeTweenProperties:{
201 value:function(eventDetail){
202 //console.log(eventDetail);
203 }
204 },
205
183 selectTween:{ 206 selectTween:{
184 value: function(){ 207 value: function(){
185 // turn on event listener for element change 208 // turn on event listener for element change
@@ -203,8 +226,9 @@ var Tween = exports.Tween = Montage.create(Component, {
203 // move animated element to correct position on stage 226 // move animated element to correct position on stage
204 var currentTop = this.tweenedProperties["top"] + "px"; 227 var currentTop = this.tweenedProperties["top"] + "px";
205 var currentLeft = this.tweenedProperties["left"] + "px"; 228 var currentLeft = this.tweenedProperties["left"] + "px";
206 ElementsMediator.setProperty([this.parentComponent.parentComponent.animatedElement], "top", [currentTop], "Change", "tween"); 229
207 ElementsMediator.setProperty([this.parentComponent.parentComponent.animatedElement], "left", [currentLeft], "Change", "tween"); 230 this.application.ninja.elementMediator.setProperty([this.parentComponent.parentComponent.animatedElement], "top", [currentTop], "Change", "tween");
231 this.application.ninja.elementMediator.setProperty([this.parentComponent.parentComponent.animatedElement], "left", [currentLeft], "Change", "tween");
208 232
209 } 233 }
210 }, 234 },
@@ -218,4 +242,5 @@ var Tween = exports.Tween = Montage.create(Component, {
218 this.keyframe.deselectKeyframe(); 242 this.keyframe.deselectKeyframe();
219 } 243 }
220 } 244 }
245
221}); 246});