aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js')
-rw-r--r--js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js25
1 files changed, 11 insertions, 14 deletions
diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
index 4a3d7a44..74a7f962 100644
--- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
+++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
@@ -229,6 +229,9 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
229 }, 229 },
230 set:function (val) { 230 set:function (val) {
231 this._trackDuration = val; 231 this._trackDuration = val;
232 if(this._trackDuration > this.application.ninja.timeline.masterDuration){
233 this.application.ninja.timeline.masterDuration = this._trackDuration;
234 }
232 } 235 }
233 }, 236 },
234 237
@@ -405,18 +408,12 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
405 408
406 insertTween:{ 409 insertTween:{
407 value:function (clickPos) { 410 value:function (clickPos) {
408
409 // calculate new tween's keyframe milliseconds by clickPos 411 // calculate new tween's keyframe milliseconds by clickPos
410 var currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80); 412 var currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80);
411 var currentMillisec = currentMillisecPerPixel * clickPos; 413 var currentMillisec = currentMillisecPerPixel * clickPos;
412 414
413 // need to check timeline master duration if greater than this track duration 415 // need to check timeline master duration if greater than this track duration
414 this.trackDuration = currentMillisec; 416 this.trackDuration = currentMillisec;
415
416 if(this.trackDuration > this.application.ninja.timeline.masterDuration){
417 this.application.ninja.timeline.masterDuration = this.trackDuration;
418 }
419
420 var newTween = {}; 417 var newTween = {};
421 418
422 if (clickPos == 0) { 419 if (clickPos == 0) {
@@ -444,9 +441,9 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
444 // update the animation duration 441 // update the animation duration
445 var animationDuration = Math.round(this.trackDuration / 1000) + "s"; 442 var animationDuration = Math.round(this.trackDuration / 1000) + "s";
446 this.ninjaStylesContoller.setElementStyle(this.animatedElement, "-webkit-animation-duration", animationDuration); 443 this.ninjaStylesContoller.setElementStyle(this.animatedElement, "-webkit-animation-duration", animationDuration);
447
448 this.nextKeyframe += 1; 444 this.nextKeyframe += 1;
449 } 445 }
446 this.application.ninja.documentController.activeDocument.needsSave = true;
450 } 447 }
451 }, 448 },
452 449
@@ -460,7 +457,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
460 retrieveStoredTweens:{ 457 retrieveStoredTweens:{
461 value:function () { 458 value:function () {
462 var percentValue, fraction, splitValue,offsetAttribute,topOffSetAttribute,leftOffsetAttribute 459 var percentValue, fraction, splitValue,offsetAttribute,topOffSetAttribute,leftOffsetAttribute
463 var animationTiming,trackTiming,currentMilliSec,currentMilliSecPerPixel,clickPosition,i = 0; 460 var currentMilliSec,currentMilliSecPerPixel,clickPosition,tempTiming,tempTimingInt,trackTiming,i = 0;
464 461
465 var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); 462 var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID);
466 this.application.ninja.timeline.arrLayers[selectedIndex].created=true; 463 this.application.ninja.timeline.arrLayers[selectedIndex].created=true;
@@ -468,11 +465,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
468 if(this.animatedElement!==undefined){ 465 if(this.animatedElement!==undefined){
469 this.animationName = this.application.ninja.stylesController.getElementStyle(this.animatedElement, "-webkit-animation-name"); 466 this.animationName = this.application.ninja.stylesController.getElementStyle(this.animatedElement, "-webkit-animation-name");
470 if(this.animationName){ 467 if(this.animationName){
471 animationTiming = this.application.ninja.stylesController.getElementStyle(this.animatedElement, "-webkit-animation-duration"); 468 trackTiming = this.application.ninja.stylesController.getElementStyle(this.animatedElement, "-webkit-animation-duration");
472 trackTiming = animationTiming.split("s");
473 currentMilliSec = trackTiming[0] * 1000;
474 currentMilliSecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80);
475 clickPosition = currentMilliSec / currentMilliSecPerPixel;
476 this.nextKeyframe = 0; 469 this.nextKeyframe = 0;
477 470
478 this.currentKeyframeRule = this.application.ninja.stylesController.getAnimationRuleWithName(this.animationName, this.application.ninja.currentDocument._document); 471 this.currentKeyframeRule = this.application.ninja.stylesController.getAnimationRuleWithName(this.animationName, this.application.ninja.currentDocument._document);
@@ -500,10 +493,13 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
500 493
501 } 494 }
502 else { 495 else {
496 tempTiming = trackTiming.split("s");
497 tempTimingInt = parseInt(tempTiming[0]);
498 this.trackDuration = tempTimingInt *1000;
503 percentValue = this.currentKeyframeRule[i].keyText; 499 percentValue = this.currentKeyframeRule[i].keyText;
504 splitValue = percentValue.split("%"); 500 splitValue = percentValue.split("%");
505 fraction = splitValue[0] / 100; 501 fraction = splitValue[0] / 100;
506 currentMilliSec = fraction * trackTiming[0] * 1000; 502 currentMilliSec = fraction * this.trackDuration;
507 currentMilliSecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80); 503 currentMilliSecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80);
508 clickPosition = currentMilliSec / currentMilliSecPerPixel; 504 clickPosition = currentMilliSec / currentMilliSecPerPixel;
509 newTween.spanWidth = clickPosition - this.tweens[this.tweens.length - 1].keyFramePosition; 505 newTween.spanWidth = clickPosition - this.tweens[this.tweens.length - 1].keyFramePosition;
@@ -564,6 +560,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
564 keyframeString += " }"; 560 keyframeString += " }";
565 // set the keyframe string as the new rule 561 // set the keyframe string as the new rule
566 this.currentKeyframeRule = this.ninjaStylesContoller.addRule(keyframeString); 562 this.currentKeyframeRule = this.ninjaStylesContoller.addRule(keyframeString);
563 this.application.ninja.documentController.activeDocument.needsSave = true;
567 } 564 }
568 }, 565 },
569 566