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.js87
1 files changed, 46 insertions, 41 deletions
diff --git a/js/panels/Timeline/Tween.reel/Tween.js b/js/panels/Timeline/Tween.reel/Tween.js
index ff8d0bad..46b2042c 100644
--- a/js/panels/Timeline/Tween.reel/Tween.js
+++ b/js/panels/Timeline/Tween.reel/Tween.js
@@ -35,6 +35,7 @@ var ElementsMediator = require("js/mediators/element-mediator").ElementMediator;
35 35
36var Tween = exports.Tween = Montage.create(Component, { 36var Tween = exports.Tween = Montage.create(Component, {
37 37
38 // ==== Begin Models
38 keyframe: { 39 keyframe: {
39 value: null, 40 value: null,
40 serializable: true 41 serializable: true
@@ -194,17 +195,17 @@ var Tween = exports.Tween = Montage.create(Component, {
194 195
195 }, 196 },
196 197
197 draw:{ 198 _initSelect:{
198 value:function () { 199 value: null
199 this.tweenspan.element.style.width = this.spanWidth + "px"; 200 },
200 this.keyframe.element.style.left = (this.spanWidth -5) + "px"; 201 initSelect:{
201 this.tweenspan.spanWidth = this.spanWidth; 202 serializable:true,
202 this.element.style.left = this.spanPosition + "px"; 203 get:function () {
203 this.keyframe.position = this.spanWidth; 204 return this._initSelect;
204 this.tweenspan.easing = this.easing; 205 },
205 if(this.isTweenAnimated){ 206 set:function (newVal) {
206 this.tweenspan.highlightSpan(); 207 this._initSelect = newVal;
207 } 208 this.tweenData.initSelect = newVal;
208 } 209 }
209 }, 210 },
210 211
@@ -218,25 +219,48 @@ var Tween = exports.Tween = Montage.create(Component, {
218 this.tweenedProperties = this.tweenData.tweenedProperties; 219 this.tweenedProperties = this.tweenData.tweenedProperties;
219 this.isTweenAnimated = this.tweenData.isTweenAnimated; 220 this.isTweenAnimated = this.tweenData.isTweenAnimated;
220 this.easing = this.tweenData.easing; 221 this.easing = this.tweenData.easing;
222 this.initSelect = this.tweenData.initSelect;
221 this.needsDraw = true; 223 this.needsDraw = true;
222 } 224 }
223 }, 225 },
226 // ==== End Models
227
228 // ==== Begin Draw cycle methods
229 prepareForDraw:{
230 value:function(){
231 if(this.initSelect){
232 this.keyframe.selectKeyframe();
233 this.initSelect = false;
234 }
235 }
236 },
237
238 draw:{
239 value:function () {
240 this.tweenspan.element.style.width = this.spanWidth + "px";
241 this.keyframe.element.style.left = (this.spanWidth -5) + "px";
242 this.tweenspan.spanWidth = this.spanWidth;
243 this.element.style.left = this.spanPosition + "px";
244 this.keyframe.position = this.spanWidth;
245 this.tweenspan.easing = this.easing;
246 if(this.isTweenAnimated){
247 this.tweenspan.highlightSpan();
248 }
249 }
250 },
251 // ==== End Draw cycle methods
224 252
253 // ==== Begin Event handlers
225 handleElementChange:{ 254 handleElementChange:{
226 value:function (event) { 255 value:function (event) {
227 // temp - testing var
228 var useAbsolute = true;
229
230 if(event.detail.type === "cssChange"){ 256 if(event.detail.type === "cssChange"){
231 event.detail.source="cssPanelChange" 257 event.detail.source="cssPanelChange"
232 } 258 }
233
234 if (event.detail.source && event.detail.source !== "tween") { 259 if (event.detail.source && event.detail.source !== "tween") {
235 260
236 if(this.parentComponent.parentComponent.isSubproperty){ 261 if(this.parentComponent.parentComponent.isSubproperty){
237 this.setStyleTweenProperty(event.detail); 262 this.setStyleTweenProperty(event.detail);
238 } else { 263 } else {
239 // check for correct element selection
240 if (this.application.ninja.selectedElements[0] != this.parentComponent.parentComponent.animatedElement) { 264 if (this.application.ninja.selectedElements[0] != this.parentComponent.parentComponent.animatedElement) {
241 console.log("Wrong element selected for this keyframe track"); 265 console.log("Wrong element selected for this keyframe track");
242 } else { 266 } else {
@@ -246,10 +270,11 @@ var Tween = exports.Tween = Montage.create(Component, {
246 } 270 }
247 } 271 }
248 }, 272 },
273 // ==== End Event handlers
249 274
275 // ==== Begin Controllers
250 setTweenProperties:{ 276 setTweenProperties:{
251 value:function (eventDetail) { 277 value:function (eventDetail) {
252
253 if (eventDetail.source === "SelectionTool" || eventDetail.source === "timeline" || eventDetail.source === "pi" || eventDetail.source === "cssPanelChange") { 278 if (eventDetail.source === "SelectionTool" || eventDetail.source === "timeline" || eventDetail.source === "pi" || eventDetail.source === "cssPanelChange") {
254 if(this.parentComponent.parentComponent.animatedElement.offsetTop != this.tweenedProperties["top"]){ 279 if(this.parentComponent.parentComponent.animatedElement.offsetTop != this.tweenedProperties["top"]){
255 this.tweenedProperties["top"] = this.parentComponent.parentComponent.animatedElement.offsetTop + "px"; 280 this.tweenedProperties["top"] = this.parentComponent.parentComponent.animatedElement.offsetTop + "px";
@@ -263,12 +288,12 @@ var Tween = exports.Tween = Montage.create(Component, {
263 if (this.parentComponent.parentComponent.animatedElement.offsetHeight != this.tweenedProperties["height"]){ 288 if (this.parentComponent.parentComponent.animatedElement.offsetHeight != this.tweenedProperties["height"]){
264 this.tweenedProperties["height"] = this.parentComponent.parentComponent.animatedElement.offsetHeight + "px"; 289 this.tweenedProperties["height"] = this.parentComponent.parentComponent.animatedElement.offsetHeight + "px";
265 } 290 }
266 // tell track to update css rule 291
267 this.parentComponent.parentComponent.updateKeyframeRule(); 292 this.parentComponent.parentComponent.updateKeyframeRule();
268 this.isTweenAnimated = true; 293 this.isTweenAnimated = true;
269 } 294 }
270 295
271 if (eventDetail.source === "translateTool") { 296 if (eventDetail.source === "translateTool" || eventDetail.source === "rotateTool") {
272 var arrMat = eventDetail.data.value[0].properties.mat, 297 var arrMat = eventDetail.data.value[0].properties.mat,
273 strTweenProperty = "perspective(1400) matrix3d(" + arrMat.join() + ")"; 298 strTweenProperty = "perspective(1400) matrix3d(" + arrMat.join() + ")";
274 299
@@ -281,26 +306,17 @@ var Tween = exports.Tween = Montage.create(Component, {
281 306
282 setStyleTweenProperty:{ 307 setStyleTweenProperty:{
283 value:function (eventDetail) { 308 value:function (eventDetail) {
284 //console.log("Setting style tween properties for: " + this.parentComponent.parentComponent.trackEditorProperty);
285 //console.log(eventDetail);
286 if(eventDetail.type == "setProperties"){ 309 if(eventDetail.type == "setProperties"){
287 // need to ignore top, left, width, and height
288 //console.log(eventDetail.data.value[0]);
289 this.tweenedProperties[this.parentComponent.parentComponent.trackEditorProperty] = eventDetail.data.value[0]; 310 this.tweenedProperties[this.parentComponent.parentComponent.trackEditorProperty] = eventDetail.data.value[0];
290 this.parentComponent.parentComponent.updatePropKeyframeRule(); 311 this.parentComponent.parentComponent.updatePropKeyframeRule();
291
292 } else if(eventDetail.type == "setColor"){ 312 } else if(eventDetail.type == "setColor"){
293 var prop = this.parentComponent.parentComponent.trackEditorProperty; 313 var prop = this.parentComponent.parentComponent.trackEditorProperty;
294 this.tweenedProperties[prop] = eventDetail.data.value.color.css; 314 this.tweenedProperties[prop] = eventDetail.data.value.color.css;
295 this.parentComponent.parentComponent.updatePropKeyframeRule(); 315 this.parentComponent.parentComponent.updatePropKeyframeRule();
296
297 } else if(eventDetail.type == "setProperty"){ 316 } else if(eventDetail.type == "setProperty"){
298 // need to ignore top, left, width, and height
299 //console.log(eventDetail.data.value[0]);
300 this.tweenedProperties[this.parentComponent.parentComponent.trackEditorProperty] = eventDetail.data.value[0]; 317 this.tweenedProperties[this.parentComponent.parentComponent.trackEditorProperty] = eventDetail.data.value[0];
301 this.parentComponent.parentComponent.updatePropKeyframeRule(); 318 this.parentComponent.parentComponent.updatePropKeyframeRule();
302 319 } else {
303 }else {
304 console.log("TWEEN Unhandled type - setStyleTweenProperty : " + eventDetail.type); 320 console.log("TWEEN Unhandled type - setStyleTweenProperty : " + eventDetail.type);
305 } 321 }
306 } 322 }
@@ -308,7 +324,6 @@ var Tween = exports.Tween = Montage.create(Component, {
308 324
309 setKeyframeEase:{ 325 setKeyframeEase:{
310 value:function(easeType){ 326 value:function(easeType){
311 // easeTypes - ease, ease-out, ease-in, ease-in-out, linear, cubic-bezier(x1, y1, x2, y2)
312 this.tweenedProperties["-webkit-animation-timing-function"] = easeType; 327 this.tweenedProperties["-webkit-animation-timing-function"] = easeType;
313 if(this.parentComponent.parentComponent.isSubproperty){ 328 if(this.parentComponent.parentComponent.isSubproperty){
314 if(this.parentComponent.parentComponent.trackType == "position"){ 329 if(this.parentComponent.parentComponent.trackType == "position"){
@@ -323,18 +338,11 @@ var Tween = exports.Tween = Montage.create(Component, {
323 338
324 selectTween:{ 339 selectTween:{
325 value: function(){ 340 value: function(){
326 // turn on event listener for element change
327 this.eventManager.addEventListener("elementChange", this, false); 341 this.eventManager.addEventListener("elementChange", this, false);
328
329 // select the containing layer
330 var selectIndex = this.application.ninja.timeline.getLayerIndexByID(this.parentComponent.parentComponent.trackID); 342 var selectIndex = this.application.ninja.timeline.getLayerIndexByID(this.parentComponent.parentComponent.trackID);
331 this.application.ninja.timeline.selectLayer(selectIndex, true); 343 this.application.ninja.timeline.selectLayer(selectIndex, true);
332
333 // tell timeline to deselect all other tweens and push this one into the selectedTweens in timeline
334 this.application.ninja.timeline.deselectTweens(); 344 this.application.ninja.timeline.deselectTweens();
335 this.application.ninja.timeline.selectedTweens.push(this); 345 this.application.ninja.timeline.selectedTweens.push(this);
336
337 // update playhead position and time text
338 this.application.ninja.timeline.playhead.style.left = (this.keyFramePosition - 2) + "px"; 346 this.application.ninja.timeline.playhead.style.left = (this.keyFramePosition - 2) + "px";
339 this.application.ninja.timeline.playheadmarker.style.left = this.keyFramePosition + "px";