diff options
-rwxr-xr-x | js/controllers/elements/element-controller.js | 13 | ||||
-rwxr-xr-x | js/mediators/element-mediator.js | 28 | ||||
-rw-r--r-- | js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 20 |
3 files changed, 47 insertions, 14 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 7f553551..45d78b33 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js | |||
@@ -11,7 +11,18 @@ exports.ElementController = Montage.create(Component, { | |||
11 | 11 | ||
12 | addElement: { | 12 | addElement: { |
13 | value: function(el, styles) { | 13 | value: function(el, styles) { |
14 | this.application.ninja.currentSelectedContainer.appendChild(el); | 14 | if(this.application.ninja.timeline.currentLayerSelected) { |
15 | var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); | ||
16 | |||
17 | if(selectedLayerIndex === 0) { | ||
18 | this.application.ninja.currentDocument.currentSelectedContainer.appendChild(el); | ||
19 | } else { | ||
20 | var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.elementsList[0]; | ||
21 | element.parentNode.insertBefore(el, element.nextSibling); | ||
22 | } | ||
23 | } else { | ||
24 | this.application.ninja.currentDocument.currentSelectedContainer.appendChild(el); | ||
25 | } | ||
15 | 26 | ||
16 | if(styles) { | 27 | if(styles) { |
17 | this.application.ninja.stylesController.setElementStyles(el, styles); | 28 | this.application.ninja.stylesController.setElementStyles(el, styles); |
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 919aaec1..06514076 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js | |||
@@ -514,11 +514,33 @@ exports.ElementMediator = Montage.create(Component, { | |||
514 | var str = this.getProperty(el, "-webkit-transform"); | 514 | var str = this.getProperty(el, "-webkit-transform"); |
515 | return str && str.length; | 515 | return str && str.length; |
516 | } | 516 | } |
517 | } | 517 | }, |
518 | |||
519 | 518 | ||
519 | reArrangeDOM:{ | ||
520 | value: function(layersDraggedArray, layerDroppedAfter) { | ||
521 | var documentRoot,length; | ||
520 | 522 | ||
523 | documentRoot = this.application.ninja.currentDocument.documentRoot; | ||
524 | length = layersDraggedArray.length; | ||
521 | 525 | ||
522 | //-------------------------------------------------------------------------------------------------------- | 526 | for(var i=0; documentRoot.children[i]; i++) { |
527 | if(documentRoot.children[i] === layerDroppedAfter.layerData.elementsList[0]) { | ||
528 | if(length >0){ | ||
529 | documentRoot.children[i].parentNode.insertBefore(layersDraggedArray[length-1].layerData.elementsList[0], documentRoot.children[i]); | ||
530 | } | ||
523 | 531 | ||
532 | /* Will require for Multiple Drag n Drop */ | ||
533 | //length = length-1; | ||
534 | //index = i; | ||
535 | //if(length>0) { | ||
536 | //while(layersDraggedArray[length]) { | ||
537 | //documentRoot.children[index].parentNode.insertBefore(layersDraggedArray[length-1].layerData.elementsList[0],documentRoot.children[k].nextSibling); | ||
538 | //length--; | ||
539 | //index++; | ||
540 | //} | ||
541 | //} | ||
542 | } | ||
543 | } | ||
544 | } | ||
545 | } | ||
524 | }); \ No newline at end of file | 546 | }); \ No newline at end of file |
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 70e04b4c..66ef1b97 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | |||
@@ -278,6 +278,12 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
278 | _dragLayerID : { | 278 | _dragLayerID : { |
279 | value: null | 279 | value: null |
280 | }, | 280 | }, |
281 | |||
282 | layersDragged:{ | ||
283 | value:[], | ||
284 | writable:true | ||
285 | }, | ||
286 | |||
281 | dragLayerID : { | 287 | dragLayerID : { |
282 | get: function() { | 288 | get: function() { |
283 | return this._dragLayerID; | 289 | return this._dragLayerID; |
@@ -302,6 +308,8 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
302 | var dragLayerIndex = this.getLayerIndexByID(this.dragLayerID), | 308 | var dragLayerIndex = this.getLayerIndexByID(this.dragLayerID), |
303 | dropLayerIndex = this.getLayerIndexByID(this.dropLayerID), | 309 | dropLayerIndex = this.getLayerIndexByID(this.dropLayerID), |
304 | dragLayer = this.arrLayers[dragLayerIndex]; | 310 | dragLayer = this.arrLayers[dragLayerIndex]; |
311 | this.layersDragged.push(dragLayer); | ||
312 | this._layerDroppedInPlace = this.arrLayers[dropLayerIndex]; | ||
305 | 313 | ||
306 | this.arrLayers.splice(dragLayerIndex, 1); | 314 | this.arrLayers.splice(dragLayerIndex, 1); |
307 | this.arrLayers.splice(dropLayerIndex, 0, dragLayer); | 315 | this.arrLayers.splice(dropLayerIndex, 0, dragLayer); |
@@ -403,6 +411,8 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
403 | this._deleteHelper = false; | 411 | this._deleteHelper = false; |
404 | } | 412 | } |
405 | } | 413 | } |
414 | this.application.ninja.elementMediator.reArrangeDOM(this.layersDragged , this._layerDroppedInPlace); | ||
415 | this.layersDragged =[]; | ||
406 | } | 416 | } |
407 | } | 417 | } |
408 | }, | 418 | }, |
@@ -903,15 +913,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
903 | } | 913 | } |
904 | }, | 914 | }, |
905 | 915 | ||
906 | |||
907 | |||
908 | |||
909 | |||
910 | |||
911 | |||
912 | |||
913 | |||
914 | |||
915 | deselectTweens:{ | 916 | deselectTweens:{ |
916 | value:function () { | 917 | value:function () { |
917 | for (var i = 0; i < this.selectedTweens.length; i++) { | 918 | for (var i = 0; i < this.selectedTweens.length; i++) { |
@@ -1038,7 +1039,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
1038 | 1039 | ||
1039 | this._openDoc = false; | 1040 | this._openDoc = false; |
1040 | 1041 | ||
1041 | |||
1042 | } | 1042 | } |
1043 | }, | 1043 | }, |
1044 | 1044 | ||