From 7845d312396e3329ac9246d4c13e99cb623216d5 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Tue, 27 Mar 2012 18:22:10 -0700 Subject: Timeline: Stability fixes for drag-and-drop and page switching. --- js/panels/Timeline/Layer.reel/Layer.js | 3 +++ js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 16 ++++++---------- js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js | 17 +++++++++++++---- 3 files changed, 22 insertions(+), 14 deletions(-) (limited to 'js/panels') diff --git a/js/panels/Timeline/Layer.reel/Layer.js b/js/panels/Timeline/Layer.reel/Layer.js index 9cf321b1..c69f28b0 100644 --- a/js/panels/Timeline/Layer.reel/Layer.js +++ b/js/panels/Timeline/Layer.reel/Layer.js @@ -417,6 +417,9 @@ var Layer = exports.Layer = Montage.create(Component, { setData:{ value:function(){ + if (typeof(this.layerData) === "undefined") { + return; + } this.layerName = this.layerData.layerName; this.layerID = this.layerData.layerID; this.arrLayerStyles = this.layerData.arrLayerStyles; diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index cb133f58..a82d3373 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -294,17 +294,13 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { if (newVal !== this._dropLayerID) { this._dropLayerID = newVal; - // Create a snapshot of arrLayers so we can manipulate it safely - var arrLayers = this.arrLayers, - dragLayerIndex = this.getLayerIndexByID(this.dragLayerID), + var dragLayerIndex = this.getLayerIndexByID(this.dragLayerID), dropLayerIndex = this.getLayerIndexByID(this.dropLayerID), - dragLayer = arrLayers[dragLayerIndex]; - - arrLayers.splice(dragLayerIndex, 1); - arrLayers.splice(dropLayerIndex, 0, dragLayer); - - // Update the repetition! - this.arrLayers = arrLayers; + dragLayer = this.arrLayers[dragLayerIndex]; + + this.arrLayers.splice(dragLayerIndex, 1); + this.arrLayers.splice(dropLayerIndex, 0, dragLayer); + this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; // Clear for future DnD this._dropLayerID = null; diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js index 5e9868f0..978b239f 100644 --- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js +++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js @@ -381,6 +381,9 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { setData:{ value:function(){ + if (typeof(this.trackData) === "undefined") { + return; + } this.bypassAnimation = this.trackData.bypassAnimation; this.trackID = this.trackData.layerID; this.tweens = this.trackData.tweens; @@ -439,9 +442,12 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { value:function () { this.ninjaStylesContoller = this.application.ninja.stylesController; var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); - if(this.application.ninja.timeline.arrLayers[selectedIndex].layerData.elementsList[0]){ - this.animatedElement = this.application.ninja.timeline.arrLayers[selectedIndex].layerData.elementsList[0]; + if (selectedIndex !== false) { + if(this.application.ninja.timeline.arrLayers[selectedIndex].layerData.elementsList[0]){ + this.animatedElement = this.application.ninja.timeline.arrLayers[selectedIndex].layerData.elementsList[0]; + } } + } }, @@ -450,9 +456,12 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { 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].layerData.created) { - this.retrieveStoredTweens(); + if (selectedIndex !== false) { + if (!this.application.ninja.timeline.arrLayers[selectedIndex].layerData.created) { + this.retrieveStoredTweens(); + } } + } } } -- cgit v1.2.3