From ab9d14780eed98f39786fae4518e69861b34bad7 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Tue, 26 Jun 2012 14:56:58 -0700 Subject: Timeline: Bug fix: Keyboard shortcut now works for adding keyframes, including splitting tweens. --- .../Timeline/TimelinePanel.reel/TimelinePanel.js | 34 +++++++++++++++++++--- .../Timeline/TimelineTrack.reel/TimelineTrack.js | 15 +++++++--- 2 files changed, 41 insertions(+), 8 deletions(-) (limited to 'js') 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, { var tempEv = {}; tempEv.offsetX = this.playheadmarker.offsetLeft; tempEv.actionType = action; - if (typeof(this.trackRepetition.childComponents[this.currentLayersSelected[0]]) !== "undefined") { - this.trackRepetition.childComponents[this.currentLayersSelected[0]].handleKeyboardShortcut(tempEv); - } else { - // oops, we do not have a layer selected. We should growl at the user. For now, this will fail silently. + + if (this.currentLayersSelected === false) { + // oops, we do not have a layer selected. We should growl at the user. For now, this will fail silently. + return; + } + + // Okay. We need to get the correct layer(s). For each currentElementSelected, + // loop through trackRepetition.childComponents and compare to stageElement. + // If they match, that's one of the components that needs the event. + var i = 0, + j = 0, + currentElementsSelectedLength = this.currentElementsSelected.length, + trackRepLength = this.trackRepetition.childComponents.length, + arrTargetIndexes = [], + arrTargetIndexesLength = 0; + + + for (i = 0; i < trackRepLength; i++) { + var currentElement = this.trackRepetition.childComponents[i].stageElement; + for (j = 0; j < currentElementsSelectedLength; j++) { + if (currentElement === this.currentElementsSelected[j]) { + arrTargetIndexes.push(i); + } + } + } + arrTargetIndexesLength = arrTargetIndexes.length; + + // Now we have an array of things that need to handle the event. + for (i = 0; i < arrTargetIndexesLength; i++) { + this.trackRepetition.childComponents[arrTargetIndexes[i]].handleKeyboardShortcut(tempEv); } } }, 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, { handleNewTween:{ value:function (ev) { + if (ev.offsetX > this.tweens[this.tweens.length - 1].tweenData.keyFramePosition) { var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); this.application.ninja.timeline.selectLayer(selectedIndex, false); @@ -750,10 +751,13 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { } else { // We will be splitting a tween. Get the x-coordinate of the mouse click within the target element. // You'd think you could use the event.x info for that, right? NO. We must use page values, calculating offsets and scrolling. - var targetElementOffset = this.findXOffset(ev.currentTarget), - position = event.pageX - targetElementOffset; - - this.splitTweenAt(position-18); + if (typeof(ev.currentTarget) === "undefined") { + this.splitTweenAt(ev.offsetX); + } else { + var targetElementOffset = this.findXOffset(ev.currentTarget), + position = event.pageX - targetElementOffset; + this.splitTweenAt(position-18); + } } } }, @@ -762,6 +766,9 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { value:function (obj) { // Here's an easy function that adds up offsets and scrolls and returns the page x value of an element var curleft = 0; + if (typeof(obj) === "undefined") { + //debugger; + } if (obj.offsetParent) { do { curleft += (obj.offsetLeft - obj.scrollLeft); -- cgit v1.2.3 From 45a5deac8ee1e38a6835275230f947b6aa8fb62a Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Tue, 26 Jun 2012 15:13:05 -0700 Subject: Timeline: Bug fix: Adding or splitting tweens on multiple layers at once will no longer change the selection. --- js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js index 297423dd..014d3f34 100644 --- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js +++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js @@ -706,6 +706,8 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { this.application.ninja.timeline.updateTimeText(currentMillisec); if (ev.shiftKey) { + var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); + this.application.ninja.timeline.selectLayer(selectedIndex, true); if (this.tweens.length < 1) { this.insertTween(0); this.addAnimationRuleToElement(ev); @@ -781,9 +783,6 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { insertTween:{ value:function (clickPos) { - var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); - this.application.ninja.timeline.selectLayer(selectedIndex, true); - var currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80); var currentMillisec = currentMillisecPerPixel * clickPos; this.trackDuration = currentMillisec; -- cgit v1.2.3