From 04f206173530b6efde16b934b1f959b255d18441 Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Fri, 22 Jun 2012 01:33:58 -0700 Subject: FIx - can't delete keyframes F5 now deletes the selected keyframe Signed-off-by: Jonathan Duran --- .../Timeline/TimelineTrack.reel/TimelineTrack.js | 60 ++++++++++++++++++---- 1 file changed, 50 insertions(+), 10 deletions(-) (limited to 'js/panels/Timeline/TimelineTrack.reel') diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js index bf380e00..85fce1ec 100644 --- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js +++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js @@ -702,17 +702,22 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { handleKeyboardShortcut:{ value:function(ev){ - if (this.tweens.length < 1) { - this.insertTween(0); - this.addAnimationRuleToElement(ev); - this.updateKeyframeRule(); - } else { - //this.handleNewTween(ev); - - // Split a tween! - this.splitTweenAt(this.application.ninja.timeline.playheadmarker.offsetLeft) - this.updateKeyframeRule(); + if(ev.actionType == "insert"){ + if (this.tweens.length < 1) { + this.insertTween(0); + this.addAnimationRuleToElement(ev); + this.updateKeyframeRule(); + } else { + this.handleNewTween(ev); + + // Split a tween! + //this.splitTweenAt(this.application.ninja.timeline.playheadmarker.offsetLeft); + this.updateKeyframeRule(); + } + } else if(ev.actionType == "remove"){ + this.removeTween(); } + } }, @@ -801,6 +806,41 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { } }, + removeTween:{ + value:function(){ + var tweenIDToRemove = this.application.ninja.timeline.selectedTweens[0].tweenID, + oldPosition = this.application.ninja.timeline.selectedTweens[0].spanPosition, + oldSpanWidth = this.application.ninja.timeline.selectedTweens[0].spanWidth; + + if(tweenIDToRemove == this.tweens[this.tweens.length-1].tweenData.tweenID){ + this.trackDuration = this.tweens[this.tweens.length-2].tweenData.keyFrameMillisec; + this.tweens.pop(); + return; + } + + // Update the next tween to have new span position and width. + this.tweens[tweenIDToRemove + 1].tweenData.spanPosition = oldPosition; + this.tweens[tweenIDToRemove + 1].spanPosition = oldPosition; + this.tweens[tweenIDToRemove + 1].tweenData.spanWidth = this.tweens[tweenIDToRemove + 1].tweenData.spanWidth + oldSpanWidth; + this.tweens[tweenIDToRemove + 1].spanWidth = this.tweens[tweenIDToRemove + 1].spanWidth + oldSpanWidth; + + // redraw the tweens + for(var i in this.tweenRepetition.childComponents){ + this.tweenRepetition.childComponents[i].setData(); + } + + // remove the selected tween + this.tweens.splice(tweenIDToRemove, 1); + this.application.ninja.currentDocument.model.needsSave = true; + + // update the tween ids + for (var j = 0; j < this.tweens.length; j++) { + this.tweens[j].tweenID = j; + this.tweens[j].tweenData.tweenID = j; + } + } + }, + createMatchingPositionSizeTween:{ value:function (newTween) { var i; -- cgit v1.2.3