aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline
diff options
context:
space:
mode:
authorJon Reid2012-06-26 14:56:58 -0700
committerJon Reid2012-06-26 14:56:58 -0700
commitab9d14780eed98f39786fae4518e69861b34bad7 (patch)
tree5e3a0a8459f078670fa7e57a017ed9c2e8c200eb /js/panels/Timeline
parent9aa987003f0c7866e66aabcc7d9cc2b9da8ed91c (diff)
downloadninja-ab9d14780eed98f39786fae4518e69861b34bad7.tar.gz
Timeline: Bug fix: Keyboard shortcut now works for adding keyframes,
including splitting tweens.
Diffstat (limited to 'js/panels/Timeline')
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js34
-rw-r--r--js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js15
2 files changed, 41 insertions, 8 deletions
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
index ceb37db6..3f1af281 100644
--- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
+++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
@@ -1090,10 +1090,36 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
1090 var tempEv = {}; 1090 var tempEv = {};
1091 tempEv.offsetX = this.playheadmarker.offsetLeft; 1091 tempEv.offsetX = this.playheadmarker.offsetLeft;
1092 tempEv.actionType = action; 1092 tempEv.actionType = action;
1093 if (typeof(this.trackRepetition.childComponents[this.currentLayersSelected[0]]) !== "undefined") { 1093
1094 this.trackRepetition.childComponents[this.currentLayersSelected[0]].handleKeyboardShortcut(tempEv); 1094 if (this.currentLayersSelected === false) {
1095 } else { 1095 // oops, we do not have a layer selected. We should growl at the user. For now, this will fail silently.
1096 // oops, we do not have a layer selected. We should growl at the user. For now, this will fail silently. 1096 return;
1097 }
1098
1099 // Okay. We need to get the correct layer(s). For each currentElementSelected,
1100 // loop through trackRepetition.childComponents and compare to stageElement.
1101 // If they match, that's one of the components that needs the event.
1102 var i = 0,
1103 j = 0,
1104 currentElementsSelectedLength = this.currentElementsSelected.length,
1105 trackRepLength = this.trackRepetition.childComponents.length,
1106 arrTargetIndexes = [],
1107 arrTargetIndexesLength = 0;
1108
1109
1110 for (i = 0; i < trackRepLength; i++) {
1111 var currentElement = this.trackRepetition.childComponents[i].stageElement;
1112 for (j = 0; j < currentElementsSelectedLength; j++) {
1113 if (currentElement === this.currentElementsSelected[j]) {
1114 arrTargetIndexes.push(i);
1115 }
1116 }
1117 }
1118 arrTargetIndexesLength = arrTargetIndexes.length;
1119
1120 // Now we have an array of things that need to handle the event.
1121 for (i = 0; i < arrTargetIndexesLength; i++) {
1122 this.trackRepetition.childComponents[arrTargetIndexes[i]].handleKeyboardShortcut(tempEv);
1097 } 1123 }
1098 } 1124 }
1099 }, 1125 },
diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
index d4eabbf5..297423dd 100644
--- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
+++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
@@ -743,6 +743,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
743 743
744 handleNewTween:{ 744 handleNewTween:{
745 value:function (ev) { 745 value:function (ev) {
746
746 if (ev.offsetX > this.tweens[this.tweens.length - 1].tweenData.keyFramePosition) { 747 if (ev.offsetX > this.tweens[this.tweens.length - 1].tweenData.keyFramePosition) {
747 var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); 748 var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID);
748 this.application.ninja.timeline.selectLayer(selectedIndex, false); 749 this.application.ninja.timeline.selectLayer(selectedIndex, false);
@@ -750,10 +751,13 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
750 } else { 751 } else {
751 // We will be splitting a tween. Get the x-coordinate of the mouse click within the target element. 752 // We will be splitting a tween. Get the x-coordinate of the mouse click within the target element.
752 // You'd think you could use the event.x info for that, right? NO. We must use page values, calculating offsets and scrolling. 753 // You'd think you could use the event.x info for that, right? NO. We must use page values, calculating offsets and scrolling.
753 var targetElementOffset = this.findXOffset(ev.currentTarget), 754 if (typeof(ev.currentTarget) === "undefined") {
754 position = event.pageX - targetElementOffset; 755 this.splitTweenAt(ev.offsetX);
755 756 } else {
756 this.splitTweenAt(position-18); 757 var targetElementOffset = this.findXOffset(ev.currentTarget),
758 position = event.pageX - targetElementOffset;
759 this.splitTweenAt(position-18);
760 }
757 } 761 }
758 } 762 }
759 }, 763 },
@@ -762,6 +766,9 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
762 value:function (obj) { 766 value:function (obj) {
763 // Here's an easy function that adds up offsets and scrolls and returns the page x value of an element 767 // Here's an easy function that adds up offsets and scrolls and returns the page x value of an element
764 var curleft = 0; 768 var curleft = 0;
769 if (typeof(obj) === "undefined") {
770 //debugger;
771 }
765 if (obj.offsetParent) { 772 if (obj.offsetParent) {
766 do { 773 do {
767 curleft += (obj.offsetLeft - obj.scrollLeft); 774 curleft += (obj.offsetLeft - obj.scrollLeft);