aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/TimelineTrack.reel
diff options
context:
space:
mode:
authorJon Reid2012-02-27 12:08:17 -0800
committerJon Reid2012-02-27 12:08:17 -0800
commitd55224f36da55e26c266a02efa6e58d4ecf1253e (patch)
tree36faa8ff93c0f7b925f5c0a7fb85b5d209da1f8e /js/panels/Timeline/TimelineTrack.reel
parentec5f81c6c0ccf865505ab82ebf9240c667f05c91 (diff)
parentcf9e9b711ba3d77a2a0888f8ab763383f53a1619 (diff)
downloadninja-d55224f36da55e26c266a02efa6e58d4ecf1253e.tar.gz
Merge remote-tracking branch 'ninja-jduran/Timeline' into Timeline-local
Diffstat (limited to 'js/panels/Timeline/TimelineTrack.reel')
-rw-r--r--js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js121
1 files changed, 61 insertions, 60 deletions
diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
index a36e666b..55c84dce 100644
--- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
+++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
@@ -331,10 +331,6 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
331 _styleCollapser:{ 331 _styleCollapser:{
332 value:null 332 value:null
333 }, 333 },
334 _openDocRedrawCheck:{
335 value:true,
336 writable:true
337 },
338 prepareForDraw:{ 334 prepareForDraw:{
339 value:function () { 335 value:function () {
340 this.init(); 336 this.init();
@@ -364,10 +360,12 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
364 360
365 didDraw:{ 361 didDraw:{
366 value:function () { 362 value:function () {
367 if(this.application.ninja.currentDocument.documentRoot.children[0]){ 363 if(!this.application.ninja.documentController.creatingNewFile){
368 if (this._openDocRedrawCheck) { 364 if(this.application.ninja.currentDocument.documentRoot.children[0]){
369 this.retrieveStoredTweens(); 365 var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID);
370 this._openDocRedrawCheck = false; 366 if(!this.application.ninja.timeline.arrLayers[selectedIndex].created){
367 this.retrieveStoredTweens();
368 }
371 } 369 }
372 } 370 }
373 } 371 }
@@ -465,60 +463,63 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
465 var percentValue, fraction, splitValue,offsetAttribute,topOffSetAttribute,leftOffsetAttribute, i = 0; 463 var percentValue, fraction, splitValue,offsetAttribute,topOffSetAttribute,leftOffsetAttribute, i = 0;
466 464
467 var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); 465 var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID);
466 this.application.ninja.timeline.arrLayers[selectedIndex].created=true;
468 this.animatedElement = this.application.ninja.timeline.arrLayers[selectedIndex].elementsList[0]; 467 this.animatedElement = this.application.ninja.timeline.arrLayers[selectedIndex].elementsList[0];
469 this.animationName = this.application.ninja.stylesController.getElementStyle(this.animatedElement, "-webkit-animation-name"); 468 if(this.animatedElement!==undefined){
470 this.animationDuration = this.application.ninja.stylesController.getElementStyle(this.animatedElement, "-webkit-animation-duration"); 469 this.animationName = this.application.ninja.stylesController.getElementStyle(this.animatedElement, "-webkit-animation-name");
471 if(this.animationDuration){ 470 if(this.animationName){
472 this.trackDuration = this.animationDuration.split("s"); 471 this.animationDuration = this.application.ninja.stylesController.getElementStyle(this.animatedElement, "-webkit-animation-duration");
473 this.currentMilliSec = this.trackDuration[0] * 1000; 472 this.trackDuration = this.animationDuration.split("s");
474 this.currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80); 473 this.currentMilliSec = this.trackDuration[0] * 1000;
475 this.clickPos = this.currentMilliSec / this.currentMillisecPerPixel; 474 this.currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80);
476 this.nextKeyframe = 0; 475 this.clickPos = this.currentMilliSec / this.currentMillisecPerPixel;
477 476 this.nextKeyframe = 0;
478 this.currentKeyframeRule = this.application.ninja.stylesController.getAnimationRuleWithName(this.animationName, this.application.ninja.currentDocument._document); 477
479 while (this.currentKeyframeRule[i]) { 478 this.currentKeyframeRule = this.application.ninja.stylesController.getAnimationRuleWithName(this.animationName, this.application.ninja.currentDocument._document);
480 var newTween = {}; 479 while (this.currentKeyframeRule[i]) {
481 480 var newTween = {};
482 offsetAttribute = this.currentKeyframeRule[i].cssText.split(" "); 481
483 topOffSetAttribute = offsetAttribute[3].split("px"); 482 offsetAttribute = this.currentKeyframeRule[i].cssText.split(" ");
484 leftOffsetAttribute = offsetAttribute[5].split("px"); 483 topOffSetAttribute = offsetAttribute[3].split("px");
485 484 leftOffsetAttribute = offsetAttribute[5].split("px");
486 parseInt(topOffSetAttribute[0]); 485
487 parseInt(leftOffsetAttribute[0]); 486 parseInt(topOffSetAttribute[0]);
488 487 parseInt(leftOffsetAttribute[0]);
489 if (this.currentKeyframeRule[i].keyText === "0%") { 488
490 newTween.spanWidth = 0; 489 if (this.currentKeyframeRule[i].keyText === "0%") {
491 newTween.keyFramePosition = 0; 490 newTween.spanWidth = 0;
492 newTween.keyFrameMillisec = 0; 491 newTween.keyFramePosition = 0;
493 newTween.tweenID = 0; 492 newTween.keyFrameMillisec = 0;
494 newTween.spanPosition = 0; 493 newTween.tweenID = 0;
495 newTween.tweenedProperties = []; 494 newTween.spanPosition = 0;
496 newTween.tweenedProperties["top"] = topOffSetAttribute[0]; 495 newTween.tweenedProperties = [];
497 newTween.tweenedProperties["left"] = leftOffsetAttribute[0]; 496 newTween.tweenedProperties["top"] = topOffSetAttribute[0];
498 this.tweens.push(newTween); 497 newTween.tweenedProperties["left"] = leftOffsetAttribute[0];
499 498 this.tweens.push(newTween);
500 } 499
501 else { 500 }
502 percentValue = this.currentKeyframeRule[i].keyText; 501 else {
503 splitValue = percentValue.split("%"); 502 percentValue = this.currentKeyframeRule[i].keyText;
504 fraction = splitValue[0] / 100; 503 splitValue = percentValue.split("%");
505 this.currentMilliSec = fraction * this.trackDuration[0] * 1000; 504 fraction = splitValue[0] / 100;
506 this.currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80); 505 this.currentMilliSec = fraction * this.trackDuration[0] * 1000;
507 this.clickPos = this.currentMilliSec / this.currentMillisecPerPixel; 506 this.currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80);
508 newTween.spanWidth = this.clickPos - this.tweens[this.tweens.length - 1].keyFramePosition; 507 this.clickPos = this.currentMilliSec / this.currentMillisecPerPixel;
509 newTween.keyFramePosition = this.clickPos; 508 newTween.spanWidth = this.clickPos - this.tweens[this.tweens.length - 1].keyFramePosition;
510 newTween.keyFrameMillisec = this.currentMilliSec; 509 newTween.keyFramePosition = this.clickPos;
511 newTween.tweenID = this.nextKeyframe; 510 newTween.keyFrameMillisec = this.currentMilliSec;
512 newTween.spanPosition = this.clickPos - newTween.spanWidth; 511 newTween.tweenID = this.nextKeyframe;
513 newTween.tweenedProperties=[]; 512 newTween.spanPosition = this.clickPos - newTween.spanWidth;
514 newTween.tweenedProperties["top"] = topOffSetAttribute[0]; 513 newTween.tweenedProperties=[];
515 newTween.tweenedProperties["left"] = leftOffsetAttribute[0]; 514 newTween.tweenedProperties["top"] = topOffSetAttribute[0];
516 this.tweens.push(newTween); 515 newTween.tweenedProperties["left"] = leftOffsetAttribute[0];
517 516 this.tweens.push(newTween);
518 517
518
519 }
520 i++;
521 this.nextKeyframe += 1;
519 } 522 }
520 i++;
521 this.nextKeyframe += 1;
522 } 523 }
523 } 524 }
524 else{ 525 else{