diff options
author | Valerio Virgillito | 2012-04-04 11:11:58 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-04-04 11:11:58 -0700 |
commit | a11ef2eed7049835c8bdfa50a2b893632c46eaa0 (patch) | |
tree | fcbb067044d339daa49622537e934bf3a309db96 /js/panels/Timeline | |
parent | c6de22bf42be90b403491b5f87b1818d9020310c (diff) | |
download | ninja-a11ef2eed7049835c8bdfa50a2b893632c46eaa0.tar.gz |
Squashed commit of Preparing for the montage undo-manager: Architecture changes
Reworked the add and remove elements into 1 function which can take 1 or more elements.
Removed the _element from the selection array
Many other changes related to those 2 changes
Undo/Redo shortcuts are now using montage undo/redo manager.
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/panels/Timeline')
-rw-r--r-- | js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 37 | ||||
-rw-r--r-- | js/panels/Timeline/Tween.reel/Tween.js | 2 |
2 files changed, 29 insertions, 10 deletions
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index a1e320c4..033d0f79 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | |||
@@ -318,7 +318,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
318 | "newLayer", | 318 | "newLayer", |
319 | "deleteLayer", | 319 | "deleteLayer", |
320 | "elementAdded", | 320 | "elementAdded", |
321 | "elementDeleted", | 321 | "elementsRemoved", |
322 | "selectionChange"], | 322 | "selectionChange"], |
323 | i, | 323 | i, |
324 | arrEventsLength = arrEvents.length; | 324 | arrEventsLength = arrEvents.length; |
@@ -826,7 +826,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
826 | for(var index=0;index<arrLayerLength;index++){ | 826 | for(var index=0;index<arrLayerLength;index++){ |
827 | if(this.arrLayers[index].layerData.layerID===dLayer[hashVariable].layerID){ | 827 | if(this.arrLayers[index].layerData.layerID===dLayer[hashVariable].layerID){ |
828 | dLayer[hashVariable].deleted = true; | 828 | dLayer[hashVariable].deleted = true; |
829 | ElementMediator.deleteElements(dLayer[hashVariable].elementsList); | 829 | ElementMediator.removeElements(dLayer[hashVariable].elementsList); |
830 | this.arrLayers.splice(index, 1); | 830 | this.arrLayers.splice(index, 1); |
831 | break; | 831 | break; |
832 | } | 832 | } |
@@ -861,18 +861,37 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
861 | } | 861 | } |
862 | }, | 862 | }, |
863 | 863 | ||
864 | handleElementDeleted:{ | 864 | handleElementsRemoved:{ |
865 | value:function (event) { | 865 | value:function (event) { |
866 | var length,lengthVal; | 866 | var length,lengthVal; |
867 | this.deleteElement = event.detail; | 867 | this.deleteElement = event.detail; |
868 | lengthVal = this.currentLayerSelected.layerData.elementsList.length - 1; | 868 | |
869 | for (length = lengthVal ;length >= 0 ;length--) { | 869 | // Handling deletion of multiple elements. |
870 | if (this.currentLayerSelected.layerData.elementsList[length] === this.deleteElement) { | 870 | // TODO: Optimize this double array loop |
871 | this.currentLayerSelected.layerData.elementsList.splice(length, 1); | 871 | if(Array.isArray(this.deleteElement)) { |
872 | break; | 872 | this.deleteElement = Array.prototype.slice.call(this.deleteElement, 0); |
873 | lengthVal = this.currentLayerSelected.layerData.elementsList.length - 1; | ||
874 | this.deleteElement.forEach(function(element) { | ||
875 | for (length = lengthVal ;length >= 0 ;length--) { | ||
876 | if (this.currentLayerSelected.layerData.elementsList[length] === element) { | ||
877 | this.currentLayerSelected.layerData.elementsList.splice(length, 1); | ||
878 | break; | ||
879 | } | ||
880 | //length--; | ||
881 | } | ||
882 | }, this); | ||
883 | } else { | ||
884 | lengthVal = this.currentLayerSelected.layerData.elementsList.length - 1; | ||
885 | for (length = lengthVal ;length >= 0 ;length--) { | ||
886 | if (this.currentLayerSelected.layerData.elementsList[length] === this.deleteElement) { | ||
887 | this.currentLayerSelected.layerData.elementsList.splice(length, 1); | ||
888 | break; | ||
889 | } | ||
890 | //length--; | ||
873 | } | 891 | } |
874 | //length--; | ||
875 | } | 892 | } |
893 | |||
894 | |||
876 | } | 895 | } |
877 | }, | 896 | }, |
878 | 897 | ||
diff --git a/js/panels/Timeline/Tween.reel/Tween.js b/js/panels/Timeline/Tween.reel/Tween.js index 2b308d9a..7339139f 100644 --- a/js/panels/Timeline/Tween.reel/Tween.js +++ b/js/panels/Timeline/Tween.reel/Tween.js | |||
@@ -162,7 +162,7 @@ var Tween = exports.Tween = Montage.create(Component, { | |||
162 | 162 | ||
163 | if (event.detail.source && event.detail.source !== "tween") { | 163 | if (event.detail.source && event.detail.source !== "tween") { |
164 | // check for correct element selection | 164 | // check for correct element selection |
165 | if (this.application.ninja.selectedElements[0]._element != this.parentComponent.parentComponent.animatedElement) { | 165 | if (this.application.ninja.selectedElements[0]!= this.parentComponent.parentComponent.animatedElement) { |
166 | console.log("Wrong element selected for this keyframe track"); | 166 | console.log("Wrong element selected for this keyframe track"); |
167 | } else { | 167 | } else { |
168 | // update tweenedProperties and tell containing track to update CSS rule | 168 | // update tweenedProperties and tell containing track to update CSS rule |