From 935d3e8b592fc9a3a6b252dd5fe0469e35b84713 Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Thu, 23 Feb 2012 12:09:23 -0800 Subject: Fix for tween repetition arrays getting overwritten on file open Signed-off-by: Jonathan Duran --- .../Timeline/TimelineTrack.reel/TimelineTrack.js | 92 +++++++++++----------- 1 file changed, 44 insertions(+), 48 deletions(-) (limited to 'js') diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js index bb1d5a1f..fddfd170 100644 --- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js +++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js @@ -357,10 +357,10 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { }, didDraw:{ - value:function(){ - if(this._openDocRedrawCheck){ - this.retrieveStoredTweens(); - this._openDocRedrawCheck=false; + value:function () { + if (this._openDocRedrawCheck) { + this.retrieveStoredTweens(); + this._openDocRedrawCheck = false; } } }, @@ -453,55 +453,51 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { }, retrieveStoredTweens:{ - value:function(){ - var percentValue,fraction,splitValue,i=0,k=0 - while(this.application.ninja.timeline.arrLayers[k]){ - this.animatedElement = this.application.ninja.timeline.arrLayers[k].elementsList[0]; - this.animationName = this.application.ninja.stylesController.getElementStyle(this.animatedElement,"-webkit-animation-name"); - this.animationDuration = this.application.ninja.stylesController.getElementStyle(this.animatedElement,"-webkit-animation-duration"); - this.trackDuration = this.animationDuration.split("s"); - this.currentMilliSec =this.trackDuration[0]*1000; + value:function () { + var percentValue, fraction, splitValue, i = 0; + + this.animatedElement = this.application.ninja.timeline.arrLayers[this.trackID - 1].elementsList[0]; + this.animationName = this.application.ninja.stylesController.getElementStyle(this.animatedElement, "-webkit-animation-name"); + this.animationDuration = this.application.ninja.stylesController.getElementStyle(this.animatedElement, "-webkit-animation-duration"); + this.trackDuration = this.animationDuration.split("s"); + this.currentMilliSec = this.trackDuration[0] * 1000; + this.currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80); + this.clickPos = this.currentMilliSec / this.currentMillisecPerPixel; + this.nextKeyframe = 0; + + this.currentKeyframeRule = this.application.ninja.stylesController.getAnimationRuleWithName(this.animationName, this.application.ninja.currentDocument._document); + while (this.currentKeyframeRule[i]) { + var newTween = {}; + if (this.currentKeyframeRule[i].keyText === "0%") { + newTween.spanWidth = 0; + newTween.keyFramePosition = 0; + newTween.keyFrameMillisec = 0; + newTween.tweenID = 0; + newTween.spanPosition = 0; + this.tweens.push(newTween); + + } + else { + percentValue = this.currentKeyframeRule[i].keyText; + splitValue = percentValue.split("%"); + fraction = splitValue[0] / 100; + this.currentMilliSec = fraction * this.trackDuration[0] * 1000; this.currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80); this.clickPos = this.currentMilliSec / this.currentMillisecPerPixel; - this.nextKeyframe=0; - - this.currentKeyframeRule = this.application.ninja.stylesController.getAnimationRuleWithName(this.animationName , this.application.ninja.currentDocument._document); - while(this.currentKeyframeRule[i]){ - var newTween = {}; - if( this.currentKeyframeRule[i].keyText==="0%"){ - newTween.spanWidth = 0; - newTween.keyFramePosition = 0; - newTween.keyFrameMillisec = 0; - newTween.tweenID = 0; - newTween.spanPosition = 0; - this.tweens.push(newTween); - - } - else{ - percentValue=this.currentKeyframeRule[i].keyText; - splitValue=percentValue.split("%"); - fraction=splitValue[0]/100; - this.currentMilliSec =fraction*this.trackDuration[0]*1000; - this.currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80); - this.clickPos = this.currentMilliSec / this.currentMillisecPerPixel; - newTween.spanWidth = this.clickPos - this.tweens[this.tweens.length - 1].keyFramePosition; - newTween.keyFramePosition = this.clickPos; - newTween.keyFrameMillisec = this.currentMilliSec; - newTween.tweenID = this.nextKeyframe; - newTween.spanPosition = this.clickPos - newTween.spanWidth; - this.tweens.push(newTween); - - - } - i++; - this.nextKeyframe+=1; - } - k++; - } + newTween.spanWidth = this.clickPos - this.tweens[this.tweens.length - 1].keyFramePosition; + newTween.keyFramePosition = this.clickPos; + newTween.keyFrameMillisec = this.currentMilliSec; + newTween.tweenID = this.nextKeyframe; + newTween.spanPosition = this.clickPos - newTween.spanWidth; + this.tweens.push(newTween); + } + i++; + this.nextKeyframe += 1; } - }, + } + }, addAnimationRuleToElement:{ value:function (tweenEvent) { -- cgit v1.2.3