From a8ea8f377919c7f1a6af69311f55fd57727d9058 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Thu, 5 Apr 2012 13:40:14 -0700 Subject: Timeline: Improved drag-and-drop performance. Also fix problems with expand/collapse getting out of synch during drag-and-drop. --- .../Timeline/TimelinePanel.reel/TimelinePanel.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'js/panels/Timeline/TimelinePanel.reel') diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 647d2f4e..2df447db 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -294,12 +294,24 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { if (newVal !== this._dropLayerID) { this._dropLayerID = newVal; - var dragLayerIndex = this.getLayerIndexByID(this.dragLayerID), + var myNewArray = [], + dragLayerIndex = this.getLayerIndexByID(this.dragLayerID), dropLayerIndex = this.getLayerIndexByID(this.dropLayerID), - dragLayer = this.arrLayers[dragLayerIndex]; + dragLayer = myNewArray[dragLayerIndex], + thing; + + // Copy arrLayers into new array; we want to avoid referencing. + for (thing in this.arrLayers) { + myNewArray[thing] = this.arrLayers[thing]; + } - this.arrLayers.splice(dragLayerIndex, 1); - this.arrLayers.splice(dropLayerIndex, 0, dragLayer); + // Operate on new array + myNewArray.splice(dragLayerIndex, 1); + myNewArray.splice(dropLayerIndex, 0, dragLayer); + + // Feed new array into repetition + this.arrLayers = myNewArray; + // Store reference in currentDocument. this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; // Clear for future DnD @@ -307,7 +319,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this._dragLayerID = null; // Sometimes, just to be fun, the drop and dragend events don't fire. - // So just in case, set the draw routine to delete the helper. + // To avoid this, set the draw routine to delete the helper here. this._deleteHelper = true; this.needsDraw = true; } -- cgit v1.2.3