From e7286bcbd82c944ffe9705d87ff23b9ea29ea7e5 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Fri, 18 May 2012 15:22:20 -0700 Subject: Timeline: Bug fixes for deleting elements. --- js/controllers/elements/element-controller.js | 12 ++---------- js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 3 +++ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 925fc959..675176e9 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -13,22 +13,14 @@ exports.ElementController = Montage.create(Component, { value: function(el, styles) { // Updated to use new methods in TimelinePanel. JR. var insertionIndex = this.application.ninja.timeline.getInsertionIndex(); - console.log("elementcontroller.addElement, insertionIndex = ", insertionIndex); - //debugger; if (insertionIndex === false) { this.application.ninja.currentSelectedContainer.appendChild(el); } else { if (insertionIndex === 0) { this.application.ninja.currentSelectedContainer.appendChild(el); } else { - /* - if (insertionIndex === this.application.ninja.timeline.arrLayers.length-1) { - this.application.ninja.currentSelectedContainer.appendChild(el); - } else { - */ - var element = this.application.ninja.timeline.arrLayers[insertionIndex].layerData.stageElement; - element.parentNode.insertBefore(el, element.nextSibling); - //} + var element = this.application.ninja.timeline.arrLayers[insertionIndex].layerData.stageElement; + element.parentNode.insertBefore(el, element.nextSibling); } } diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 6155ce3b..43ffaab2 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -1239,6 +1239,9 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { for (j = 0; j < arrLayersLength; j++) { if (this.arrLayers[j].layerData.stageElement == currentTest) { this.arrLayers.splice(j, 1); + // Super-secret magic trick: Now that we've spliced out an element, + // arrLayers.length is different. We need to update it. + arrLayersLength = this.arrLayers.length; } } } -- cgit v1.2.3