aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/TimelinePanel.reel
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Timeline/TimelinePanel.reel')
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js137
1 files changed, 92 insertions, 45 deletions
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
index a82d3373..110f0336 100644
--- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
+++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
@@ -305,9 +305,23 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
305 // Clear for future DnD 305 // Clear for future DnD
306 this._dropLayerID = null; 306 this._dropLayerID = null;
307 this._dragLayerID = null; 307 this._dragLayerID = null;
308
309 // 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.
311 this._deleteHelper = true;
312 this.needsDraw = true;
308 } 313 }
309 } 314 }
310 }, 315 },
316 _appendHelper: {
317 value: false
318 },
319 _deleteHelper: {
320 value: false
321 },
322 _scrollTracks: {
323 value: false
324 },
311 /* === END: Models === */ 325 /* === END: Models === */
312 /* === BEGIN: Draw cycle === */ 326 /* === BEGIN: Draw cycle === */
313 prepareForDraw:{ 327 prepareForDraw:{
@@ -329,7 +343,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
329 willDraw:{ 343 willDraw:{
330 value:function () { 344 value:function () {
331 if (this._isLayer) { 345 if (this._isLayer) {
332 // this.createNewLayer();
333 this._isLayer = false; 346 this._isLayer = false;
334 } 347 }
335 } 348 }
@@ -351,6 +364,31 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
351 } 364 }
352 this._dragAndDropHelperCoords = false; 365 this._dragAndDropHelperCoords = false;
353 } 366 }
367 // Do we need to scroll the tracks?
368 if (this._scrollTracks !== false) {
369 this.layout_tracks.scrollTop = this._scrollTracks;
370 this._scrollTracks = false;
371 }
372 // Do we have a helper to delete?
373 if (this._deleteHelper === true) {
374 if (this._dragAndDropHelper === null) {
375 // Problem....maybe a helper didn't get appended, or maybe it didn't get stored.
376 // Try and recover the helper so we can delete it.
377 var myHelper = this.container_layers.querySelector(".timeline-dnd-helper");
378 if (myHelper != null) {
379 this._dragAndDropHelper = myHelper;
380 }
381 }
382 if (this._dragAndDropHelper !== null) {
383 // We need to delete the helper. Can we delete it from container_layers?
384 if (this._dragAndDropHelper && this._dragAndDropHelper.parentNode === this.container_layers) {
385 this.container_layers.removeChild(this._dragAndDropHelper);
386 this._dragAndDropHelper = null;
387 this._deleteHelper = false;
388 }
389 }
390
391 }
354 } 392 }
355 }, 393 },
356 /* === END: Draw cycle === */ 394 /* === END: Draw cycle === */
@@ -702,41 +740,42 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
702 740
703 createNewLayer:{ 741 createNewLayer:{
704 value:function (object) { 742 value:function (object) {
705 var hashVariable = 0; 743 var hashVariable = 0,
744 newLayerName = "",
745 thingToPush = this.createLayerTemplate(),
746 myIndex = 0,
747 i = 0,
748 arrLayersLength = this.arrLayers.length;
706 749
707 var newLayerName = "", 750 this.currentLayerNumber = this.currentLayerNumber + 1;
708 thingToPush = this.createLayerTemplate(), 751 newLayerName = "Layer " + this.currentLayerNumber;
709 myIndex = 0; 752 thingToPush.layerData.layerName = newLayerName;
753 thingToPush.layerData.layerID = this.currentLayerNumber;
754 thingToPush.parentElement = this.application.ninja.currentSelectedContainer;
755 thingToPush.layerData.isSelected = true;
756 thingToPush.layerData._isFirstDraw = true;
757 thingToPush.layerData.created = true;
758
759 for (i = 0; i < this.arrLayersLength; i++) {
760 this.arrLayers[i].layerData.isSelected = false;
761 this.arrLayers[i].layerData._isFirstDraw = false;
762 }
710 763
711 this.currentLayerNumber = this.currentLayerNumber + 1; 764 if (this.layerRepetition.selectedIndexes) {
712 newLayerName = "Layer " + this.currentLayerNumber; 765 // There is a selected layer, so we need to splice the new layer on top of it.
713 thingToPush.layerData.layerName = newLayerName; 766 myIndex = this.layerRepetition.selectedIndexes[0];
714 thingToPush.layerData.layerID = this.currentLayerNumber; 767 thingToPush.layerData.layerPosition = myIndex;
715 thingToPush.parentElement = this.application.ninja.currentSelectedContainer; 768 thingToPush.layerData.trackPosition = myIndex;
716 thingToPush.layerData.isSelected = true; 769 this.arrLayers.splice(myIndex, 0, thingToPush);
717 thingToPush.layerData._isFirstDraw = true;
718 thingToPush.layerData.created = true;
719 770
720 for (var i = 0; i < this.arrLayers.length; i++) { 771 } else {
721 this.arrLayers[i].layerData.isSelected = false; 772 thingToPush.layerData.layerPosition = myIndex;
722 this.arrLayers[i].layerData._isFirstDraw = false; 773 this.arrLayers.splice(myIndex, 0, thingToPush);
723 }
724 774
725 if (this.layerRepetition.selectedIndexes) { 775 }
726 // There is a selected layer, so we need to splice the new layer on top of it.
727 myIndex = this.layerRepetition.selectedIndexes[0];
728 thingToPush.layerData.layerPosition = myIndex;
729 thingToPush.layerData.trackPosition = myIndex;
730 this.arrLayers.splice(myIndex, 0, thingToPush);
731 776
732 } else { 777 this.selectLayer(myIndex);
733 thingToPush.layerData.layerPosition = myIndex;
734 this.arrLayers.splice(myIndex, 0, thingToPush);
735 778
736 }
737
738 this.selectLayer(myIndex);
739// }
740 } 779 }
741 }, 780 },
742 781
@@ -1032,6 +1071,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
1032 // Get the offset 1071 // Get the offset
1033 var findYOffset = function(obj) { 1072 var findYOffset = function(obj) {
1034 var curleft = curtop = 0; 1073 var curleft = curtop = 0;
1074
1035 if (obj.offsetParent) { 1075 if (obj.offsetParent) {
1036 do { 1076 do {
1037 curleft += obj.offsetLeft; 1077 curleft += obj.offsetLeft;
@@ -1043,37 +1083,44 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
1043 } 1083 }
1044 this._dragAndDropHelperOffset = findYOffset(this.container_layers); 1084 this._dragAndDropHelperOffset = findYOffset(this.container_layers);
1045 this._appendHelper = true; 1085 this._appendHelper = true;
1046 // this.container_layers.appendChild(this._dragAndDropHelper); 1086 this._deleteHelper = false;
1047 } 1087 }
1048 }, 1088 },
1049 handleLayerDragover: { 1089 handleLayerDragover: {
1050 value: function(event) { 1090 value: function(event) {
1051 var currPos = 0; 1091 var currPos = 0,
1052 currPos = event.y - this._dragAndDropHelperOffset -28; 1092 myScrollTest = ((event.y - (this._dragAndDropHelperOffset - this.user_layers.scrollTop)) + 28) - this.user_layers.scrollTop;
1093 if ((myScrollTest < 60) && (this.user_layers.scrollTop >0)) {
1094 this._scrollTracks = (this.user_layers.scrollTop - 10)
1095 }
1096 if ((myScrollTest < 50) && (this.user_layers.scrollTop >0)) {
1097 this._scrollTracks = (this.user_layers.scrollTop - 20)
1098 }
1099 if ((myScrollTest > (this.user_layers.clientHeight + 10))) {
1100 this._scrollTracks = (this.user_layers.scrollTop + 10)
1101 }
1102 if ((myScrollTest > (this.user_layers.clientHeight + 20))) {
1103 this._scrollTracks = (this.user_layers.scrollTop + 20)
1104
1105 }
1106 currPos = event.y - (this._dragAndDropHelperOffset - this.user_layers.scrollTop)- 28;
1053 this._dragAndDropHelperCoords = currPos + "px"; 1107 this._dragAndDropHelperCoords = currPos + "px";
1054 this.needsDraw = true; 1108 this.needsDraw = true;
1055 } 1109 }
1056 }, 1110 },
1057 handleLayerDragEnd : { 1111 handleLayerDragEnd : {
1058 value: function(event) { 1112 value: function(event) {
1059 // Delete the helper and clean up 1113 this._deleteHelper = true;
1060 if (this._dragAndDropHelper !== null) { 1114 this.needsDraw = true;
1061 this.container_layers.removeChild(this._dragAndDropHelper); 1115
1062 this._dragAndDropHelper = null;
1063 }
1064 } 1116 }
1065 }, 1117 },
1066 handleLayerDrop : { 1118 handleLayerDrop : {