From 125723cf19cf70121bc694909d09a301ca2fc2d6 Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Mon, 27 Feb 2012 11:40:52 -0800 Subject: Timeline: RetrieveStoredTweens calling fixed Signed-off-by: Kruti Shah Signed-off-by: Jonathan Duran --- .../Timeline/TimelinePanel.reel/TimelinePanel.js | 19 ++-- .../Timeline/TimelineTrack.reel/TimelineTrack.js | 121 +++++++++++---------- 2 files changed, 71 insertions(+), 69 deletions(-) (limited to 'js/panels/Timeline') diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 797a7cbf..92bb3405 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -224,13 +224,15 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this._hashKey = "123"; _firstLayerDraw = false; - if(this.application.ninja.currentDocument.documentRoot.children[0]){ - myIndex=0; - while(this.application.ninja.currentDocument.documentRoot.children[myIndex]) - { - this._openDoc=true; - NJevent('newLayer',{key:this._hashKey,ele:this.application.ninja.currentDocument.documentRoot.children[myIndex]}) - myIndex++; + if(!this.application.ninja.documentController.creatingNewFile){ + if(this.application.ninja.currentDocument.documentRoot.children[0]){ + myIndex=0; + while(this.application.ninja.currentDocument.documentRoot.children[myIndex]) + { + this._openDoc=true; + NJevent('newLayer',{key:this._hashKey,ele:this.application.ninja.currentDocument.documentRoot.children[myIndex]}) + myIndex++; + } } }else{ NJevent('newLayer', this._hashKey); @@ -476,6 +478,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { thingToPush.elementsList = []; thingToPush.deleted = false; thingToPush.isSelected = false; + thingToPush.created=false; if (_firstLayerDraw) { this.application.ninja.currentSelectedContainer.uuid=this._hashKey; @@ -735,7 +738,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } } hashLayerObject[key][index] = value; - console.log(hashLayerObject) this.counter = 0; } }, @@ -830,7 +832,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } this.mappingArray[key]["ele"] = value; this.mappingArray[key].layerID = layer.layerID; - console.log(this.mappingArray) } }, 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, { _styleCollapser:{ value:null }, - _openDocRedrawCheck:{ - value:true, - writable:true - }, prepareForDraw:{ value:function () { this.init(); @@ -364,10 +360,12 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { didDraw:{ value:function () { - if(this.application.ninja.currentDocument.documentRoot.children[0]){ - if (this._openDocRedrawCheck) { - this.retrieveStoredTweens(); - this._openDocRedrawCheck = false; + if(!this.application.ninja.documentController.creatingNewFile){ + if(this.application.ninja.currentDocument.documentRoot.children[0]){ + var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); + if(!this.application.ninja.timeline.arrLayers[selectedIndex].created){ + this.retrieveStoredTweens(); + } } } } @@ -465,60 +463,63 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { var percentValue, fraction, splitValue,offsetAttribute,topOffSetAttribute,leftOffsetAttribute, i = 0; var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); + this.application.ninja.timeline.arrLayers[selectedIndex].created=true; this.animatedElement = this.application.ninja.timeline.arrLayers[selectedIndex].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"); - if(this.animationDuration){ - 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 = {}; - - offsetAttribute = this.currentKeyframeRule[i].cssText.split(" "); - topOffSetAttribute = offsetAttribute[3].split("px"); - leftOffsetAttribute = offsetAttribute[5].split("px"); - - parseInt(topOffSetAttribute[0]); - parseInt(leftOffsetAttribute[0]); - - if (this.currentKeyframeRule[i].keyText === "0%") { - newTween.spanWidth = 0; - newTween.keyFramePosition = 0; - newTween.keyFrameMillisec = 0; - newTween.tweenID = 0; - newTween.spanPosition = 0; - newTween.tweenedProperties = []; - newTween.tweenedProperties["top"] = topOffSetAttribute[0]; - newTween.tweenedProperties["left"] = leftOffsetAttribute[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; - newTween.tweenedProperties=[]; - newTween.tweenedProperties["top"] = topOffSetAttribute[0]; - newTween.tweenedProperties["left"] = leftOffsetAttribute[0]; - this.tweens.push(newTween); - - + if(this.animatedElement!==undefined){ + this.animationName = this.application.ninja.stylesController.getElementStyle(this.animatedElement, "-webkit-animation-name"); + if(this.animationName){ + 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 = {}; + + offsetAttribute = this.currentKeyframeRule[i].cssText.split(" "); + topOffSetAttribute = offsetAttribute[3].split("px"); + leftOffsetAttribute = offsetAttribute[5].split("px"); + + parseInt(topOffSetAttribute[0]); + parseInt(leftOffsetAttribute[0]); + + if (this.currentKeyframeRule[i].keyText === "0%") { + newTween.spanWidth = 0; + newTween.keyFramePosition = 0; + newTween.keyFrameMillisec = 0; + newTween.tweenID = 0; + newTween.spanPosition = 0; + newTween.tweenedProperties = []; + newTween.tweenedProperties["top"] = topOffSetAttribute[0]; + newTween.tweenedProperties["left"] = leftOffsetAttribute[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; + newTween.tweenedProperties=[]; + newTween.tweenedProperties["top"] = topOffSetAttribute[0]; + newTween.tweenedProperties["left"] = leftOffsetAttribute[0]; + this.tweens.push(newTween); + + + } + i++; + this.nextKeyframe += 1; } - i++; - this.nextKeyframe += 1; } } else{ -- cgit v1.2.3