aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/TimelinePanel.reel
diff options
context:
space:
mode:
authorJon Reid2012-04-05 13:40:14 -0700
committerJon Reid2012-04-05 13:40:14 -0700
commita8ea8f377919c7f1a6af69311f55fd57727d9058 (patch)
tree460a2a54613159285cc0a9985bc6aaa4e40a5416 /js/panels/Timeline/TimelinePanel.reel
parenta36266b640207b3a95aaa145def263a469ecee15 (diff)
downloadninja-a8ea8f377919c7f1a6af69311f55fd57727d9058.tar.gz
Timeline: Improved drag-and-drop performance. Also fix problems with
expand/collapse getting out of synch during drag-and-drop.
Diffstat (limited to 'js/panels/Timeline/TimelinePanel.reel')
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js22
1 files changed, 17 insertions, 5 deletions
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, {
294 if (newVal !== this._dropLayerID) { 294 if (newVal !== this._dropLayerID) {
295 this._dropLayerID = newVal; 295 this._dropLayerID = newVal;
296 296
297 var dragLayerIndex = this.getLayerIndexByID(this.dragLayerID), 297 var myNewArray = [],
298 dragLayerIndex = this.getLayerIndexByID(this.dragLayerID),
298 dropLayerIndex = this.getLayerIndexByID(this.dropLayerID), 299 dropLayerIndex = this.getLayerIndexByID(this.dropLayerID),
299 dragLayer = this.arrLayers[dragLayerIndex]; 300 dragLayer = myNewArray[dragLayerIndex],
301 thing;
302
303 // Copy arrLayers into new array; we want to avoid referencing.
304 for (thing in this.arrLayers) {
305 myNewArray[thing] = this.arrLayers[thing];
306 }
300 307
301 this.arrLayers.splice(dragLayerIndex, 1); 308 // Operate on new array
302 this.arrLayers.splice(dropLayerIndex, 0, dragLayer); 309 myNewArray.splice(dragLayerIndex, 1);
310 myNewArray.splice(dropLayerIndex, 0, dragLayer);
311
312 // Feed new array into repetition
313 this.arrLayers = myNewArray;
314 // Store reference in currentDocument.
303 this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; 315 this.application.ninja.currentDocument.tlArrLayers = this.arrLayers;
304 316
305 // Clear for future DnD 317 // Clear for future DnD
@@ -307,7 +319,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
307 this._dragLayerID = null; 319 this._dragLayerID = null;
308 320
309 // Sometimes, just to be fun, the drop and dragend events don't fire. 321 // Sometimes, just to be fun, the drop and dragend events don't fire.
310 // So just in case, set the draw routine to delete the helper. 322 // To avoid this, set the draw routine to delete the helper here.
311 this._deleteHelper = true; 323 this._deleteHelper = true;
312 this.needsDraw = true; 324 this.needsDraw = true;
313 } 325 }