diff options
Diffstat (limited to 'js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js')
-rw-r--r-- | js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js | 143 |
1 files changed, 39 insertions, 104 deletions
diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js index 1731213b..83aef230 100644 --- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js +++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js | |||
@@ -355,6 +355,25 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { | |||
355 | _dragAndDropHelperCoords: { | 355 | _dragAndDropHelperCoords: { |
356 | value: false | 356 | value: false |
357 | }, | 357 | }, |
358 | dragAndDropHelperCoords: { | ||
359 | get: function() { | ||
360 | return this._dragAndDropHelperCoords; | ||
361 | }, | ||
362 | set: function(newVal) { | ||
363 | this._dragAndDropHelperCoords = newVal; | ||
364 | } | ||
365 | }, | ||
366 | _draggingIndex: { | ||
367 | value: false | ||
368 | }, | ||
369 | draggingIndex: { | ||
370 | get: function() { | ||
371 | return this._draggingIndex; | ||
372 | }, | ||
373 | set: function(newVal) { | ||
374 | this._draggingIndex = newVal; | ||
375 | } | ||
376 | }, | ||
358 | _dragAndDropHelperOffset : { | 377 | _dragAndDropHelperOffset : { |
359 | value: false | 378 | value: false |
360 | }, | 379 | }, |
@@ -443,10 +462,10 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { | |||
443 | this.eventManager.addEventListener("tlZoomSlider", this, false); | 462 | this.eventManager.addEventListener("tlZoomSlider", this, false); |
444 | 463 | ||
445 | // Drag and Drop event handlers | 464 | // Drag and Drop event handlers |
446 | this.element.addEventListener("dragover", this.handleKeyframeDragover.bind(this), false); | 465 | //this.element.addEventListener("dragover", this.handleKeyframeDragover.bind(this), false); |
447 | this.element.addEventListener("dragstart", this.handleKeyframeDragstart.bind(this), false); | 466 | this.element.addEventListener("dragstart", this.handleKeyframeDragstart.bind(this), false); |
448 | this.element.addEventListener("dragend", this.handleKeyframeDragend.bind(this), false); | 467 | this.element.addEventListener("dragend", this.handleKeyframeDragend.bind(this), false); |
449 | this.element.addEventListener("drop", this.handleKeyframeDrop.bind(this), false); | 468 | //this.element.addEventListener("drop", this.handleKeyframeDrop.bind(this), false); |
450 | } | 469 | } |
451 | }, | 470 | }, |
452 | 471 | ||
@@ -937,127 +956,43 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { | |||
937 | 956 | ||
938 | //this._dragAndDropHelper.style.width = window.getComputedStyle(this.container_layers, null).getPropertyValue("width"); | 957 | //this._dragAndDropHelper.style.width = window.getComputedStyle(this.container_layers, null).getPropertyValue("width"); |
939 | this._dragAndDropHelper.classList.add("track-dnd-helper"); | 958 | this._dragAndDropHelper.classList.add("track-dnd-helper"); |
940 | 959 | ||
941 | // Get the offset | 960 | if (this.draggingIndex < (this.tweens.length -1)) { |
942 | var findYOffset = function(obj) { | 961 | maxPosition = this.tweenRepetition.childComponents[this.draggingIndex+1].keyFramePosition; |
943 | var curleft = curtop = 0; | ||
944 | |||
945 | if (obj.offsetParent) { | ||
946 | do { | ||
947 | curleft += obj.offsetLeft; | ||
948 | curtop += obj.offsetTop; | ||
949 | |||
950 | } while (obj = obj.offsetParent); | ||
951 | } | ||
952 | return curtop; | ||
953 | } | ||
954 | //this._dragAndDropHelperOffset = findYOffset(this.container_layers); | ||
955 | if (this.draggingIndex !== (this.tweens.length -1)) { | ||
956 | maxPosition = this.tweenRepetition.childComponents[this.draggingIndex +1].keyFramePosition; | ||
957 | } | 962 | } |
958 | if (this.draggingIndex > 1) { | 963 | if (this.draggingIndex > 1) { |
959 | minPosition = this.tweenRepetition.childComponents[this.draggingIndex -1].keyFramePosition; | 964 | minPosition = this.tweenRepetition.childComponents[this.draggingIndex-1].keyFramePosition; |
960 | } | 965 | } |
961 | this._keyframeMinPosition = minPosition+2; | 966 | this._keyframeMinPosition = minPosition+2; |
962 | this._keyframeMaxPosition = maxPosition-9; | 967 | this._keyframeMaxPosition = maxPosition-9; |
963 | this._appendHelper = true; | 968 | this._appendHelper = true; |
964 | this._deleteHelper = false; | 969 | this._deleteHelper = false; |
965 | } | ||
966 | }, | ||
967 | handleKeyframeDragover: { | ||
968 | value: function(event) { | ||
969 | event.preventDefault(); | ||
970 | var currPos = 0; | ||
971 | /* | ||
972 | myScrollTest = ((event.y - (this._dragAndDropHelperOffset - this.user_layers.scrollTop)) + 28) - this.user_layers.scrollTop; | ||
973 | if ((myScrollTest < 60) && (this.user_layers.scrollTop >0)) { | ||
974 | this._scrollTracks = (this.user_layers.scrollTop - 10) | ||
975 | } | ||
976 | if ((myScrollTest < 50) && (this.user_layers.scrollTop >0)) { | ||
977 | this._scrollTracks = (this.user_layers.scrollTop - 20) | ||
978 | } | ||
979 | if ((myScrollTest > (this.user_layers.clientHeight + 10))) { | ||
980 | this._scrollTracks = (this.user_layers.scrollTop + 10) | ||
981 | } | ||
982 | if ((myScrollTest > (this.user_layers.clientHeight + 20))) { | ||
983 | this._scrollTracks = (this.user_layers.scrollTop + 20) | ||
984 | |||
985 | } | ||
986 | */ | ||
987 | //currPos = event.y - (this._dragAndDropHelperOffset - this.user_layers.scrollTop)- 28; | ||
988 | currPos = event.x - 277; | ||
989 | 970 | ||
990 | // too much or too little? | 971 | // Get my index in the track array |
991 | if (currPos < this._keyframeMinPosition) { | 972 | var i = 0, |
992 | currPos = this._keyframeMinPosition; | 973 | arrLayersLength = this.parentComponent.parentComponent.arrLayers.length, |
993 | } | 974 | myId = null; |
994 | if (currPos > this._keyframeMaxPosition) { | 975 | for (i = 0; i < arrLayersLength; i++) { |
995 | currPos = this._keyframeMaxPosition; | 976 | var currUuid = this.parentComponent.parentComponent.trackRepetition.childComponents[i].uuid; |
977 | if ( currUuid === this.uuid) { | ||
978 | myId = i; | ||
979 | } | ||
996 | } | 980 | } |
997 | 981 | this.parentComponent.parentComponent.draggingTrackId = myId; | |
998 | this._dragAndDropHelperCoords = currPos + "px"; | 982 | this.parentComponent.parentComponent.draggingType = "keyframe"; |
999 | this.needsDraw = true; | ||
1000 | return false; | ||
1001 | } | 983 | } |
1002 | }, | 984 | }, |
1003 | |||
1004 | handleKeyframeDragend : { | 985 | handleKeyframeDragend : { |
1005 | value: function(event) { | 986 | value: function(event) { |
987 | if (this.parentComponent.parentComponent.draggingType !== "keyframe") { | ||
988 | return; | ||
989 | } | ||
1006 | this._deleteHelper = true; | 990 | this._deleteHelper = true; |
1007 | this.needsDraw = true; | 991 | this.needsDraw = true; |
1008 | 992 | ||
1009 | } | 993 | } |
1010 | }, | 994 | }, |
1011 | 995 | ||
1012 | handleKeyframeDrop : { | ||
1013 | value: function(event) { | ||
1014 | event.stopPropagation(); | ||
1015 | //this.element.classList.remove("dragOver"); | ||
1016 | //if (this.parentComponent.parentComponent.dragLayerID !== this.layerID) { | ||
1017 | //this.parentComponent.parentComponent.dropLayerID = this.layerID; | ||
1018 | //} | ||
1019 | |||
1020 | /* | ||
1021 | * First, what keyframe is it (get the index); | ||
1022 | * Limit keyframe position to between index-1 and index+1 keyFramePosition | ||
1023 | * On update, be sure to update index+1's information too | ||
1024 | * | ||
1025 | */ | ||
1026 | |||
1027 | var currPos = event.x - 274, | ||
1028 | currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80), | ||
1029 | currentMillisec = 0, | ||
1030 | i = 0, | ||
1031 | tweenIndex = this.draggingIndex; | ||
1032 | |||
1033 | // too much or too little? | ||
1034 | if (currPos < this._keyframeMinPosition) { | ||
1035 | currPos = this._keyframeMinPosition + 3; | ||
1036 | } | ||
1037 | if (currPos > this._keyframeMaxPosition) { | ||
1038 | currPos = this._keyframeMaxPosition + 3; | ||
1039 | } | ||
1040 | |||
1041 | currentMillisec = currentMillisecPerPixel * currPos; | ||
1042 | |||
1043 | this.tweens[tweenIndex].tweenData.spanWidth = currPos - this.tweens[tweenIndex - 1].tweenData.keyFramePosition; | ||
1044 | this.tweens[tweenIndex].tweenData.keyFramePosition = currPos; | ||
1045 | this.tweens[tweenIndex].tweenData.keyFrameMillisec = currentMillisec; | ||
1046 | this.tweens[tweenIndex].tweenData.spanPosition = currPos - this.tweens[tweenIndex].tweenData.spanWidth; | ||
1047 | this.tweenRepetition.childComponents[tweenIndex].setData(); | ||
1048 | if (tweenIndex < this.tweens.length -1) { | ||
1049 | var spanWidth = this.tweens[tweenIndex +1].tweenData.keyFramePosition - currPos; | ||
1050 | var spanPosition = currPos; | ||
1051 | this.tweens[tweenIndex +1].tweenData.spanWidth = spanWidth; | ||
1052 | this.tweens[tweenIndex +1].tweenData.spanPosition = currPos; | ||
1053 | this.tweenRepetition.childComponents[tweenIndex+1].setData(); | ||
1054 | } | ||
1055 | this.tweenRepetition.childComponents[tweenIndex].selectTween(); | ||
1056 | this.updateKeyframeRule(); | ||
1057 | return false; | ||
1058 | } | ||
1059 | }, | ||
1060 | |||
1061 | 996 | ||
1062 | /* Begin: Logging routines */ | 997 | /* Begin: Logging routines */ |
1063 | _boolDebug: { | 998 | _boolDebug: { |