From 00111421bb76e80c511692b58b7eddd598286e76 Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Sat, 29 Sep 2012 20:37:35 -0700 Subject: [PATCH] BOOM nice bouncing effect and prompt updates --- src/animationFactory.js | 6 ++++-- src/commandViews.js | 21 +++++++++++++++++---- src/style/main.css | 6 +++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/animationFactory.js b/src/animationFactory.js index e39ba6c3..5e9155cd 100644 --- a/src/animationFactory.js +++ b/src/animationFactory.js @@ -19,6 +19,7 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co } var time = GRAPHICS.defaultAnimationTime * 1.0; + var bounceTime = time * 2; // essentially refresh the entire tree, but do a special thing for the commit var visNode = commit.get('visNode'); @@ -31,11 +32,12 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co visNode.setOutgoingEdgesBirthPosition(); visNode.parentInFront(); - visNode.animateUpdatedPosition(time); + visNode.animateUpdatedPosition(bounceTime, 'bounce'); visNode.animateOutgoingEdges(time); }; animationQueue.add(new Animation({ - closure: animation + closure: animation, + duration: Math.max(time, bounceTime) })); }; diff --git a/src/commandViews.js b/src/commandViews.js index 0a39640a..55b471b6 100644 --- a/src/commandViews.js +++ b/src/commandViews.js @@ -14,16 +14,21 @@ var CommandPromptView = Backbone.View.extend({ }, events: { - 'keyup #commandTextField': 'keyUp' + 'keydown #commandTextField': 'onKey', + 'keyup #commandTextField': 'onKeyUp' }, focus: function() { this.$('#commandTextField').focus(); }, - keyUp: function(e) { + onKey: function(e) { var el = e.srcElement; this.updatePrompt(el) + }, + + onKeyUp: function(e) { + this.onKey(e); // we need to capture some of these events. // WARNING: this key map is not internationalized :( @@ -45,10 +50,18 @@ var CommandPromptView = Backbone.View.extend({ if (keyMap[e.which] !== undefined) { e.preventDefault(); keyMap[e.which](); - this.updatePrompt(el); + this.onKey(e); } }, + badHtmlEncode: function(text) { + return text.replace(/&/g,'&') + .replace(/