BOOM nice bouncing effect and prompt updates

This commit is contained in:
Peter Cottle 2012-09-29 20:37:35 -07:00
parent 986a2162af
commit 00111421bb
3 changed files with 24 additions and 9 deletions

View file

@ -19,6 +19,7 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
} }
var time = GRAPHICS.defaultAnimationTime * 1.0; var time = GRAPHICS.defaultAnimationTime * 1.0;
var bounceTime = time * 2;
// essentially refresh the entire tree, but do a special thing for the commit // essentially refresh the entire tree, but do a special thing for the commit
var visNode = commit.get('visNode'); var visNode = commit.get('visNode');
@ -31,11 +32,12 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
visNode.setOutgoingEdgesBirthPosition(); visNode.setOutgoingEdgesBirthPosition();
visNode.parentInFront(); visNode.parentInFront();
visNode.animateUpdatedPosition(time); visNode.animateUpdatedPosition(bounceTime, 'bounce');
visNode.animateOutgoingEdges(time); visNode.animateOutgoingEdges(time);
}; };
animationQueue.add(new Animation({ animationQueue.add(new Animation({
closure: animation closure: animation,
duration: Math.max(time, bounceTime)
})); }));
}; };

View file

@ -14,16 +14,21 @@ var CommandPromptView = Backbone.View.extend({
}, },
events: { events: {
'keyup #commandTextField': 'keyUp' 'keydown #commandTextField': 'onKey',
'keyup #commandTextField': 'onKeyUp'
}, },
focus: function() { focus: function() {
this.$('#commandTextField').focus(); this.$('#commandTextField').focus();
}, },
keyUp: function(e) { onKey: function(e) {
var el = e.srcElement; var el = e.srcElement;
this.updatePrompt(el) this.updatePrompt(el)
},
onKeyUp: function(e) {
this.onKey(e);
// we need to capture some of these events. // we need to capture some of these events.
// WARNING: this key map is not internationalized :( // WARNING: this key map is not internationalized :(
@ -45,10 +50,18 @@ var CommandPromptView = Backbone.View.extend({
if (keyMap[e.which] !== undefined) { if (keyMap[e.which] !== undefined) {
e.preventDefault(); e.preventDefault();
keyMap[e.which](); keyMap[e.which]();
this.updatePrompt(el); this.onKey(e);
} }
}, },
badHtmlEncode: function(text) {
return text.replace(/&/g,'&')
.replace(/</g,'&lt;')
.replace(/</g,'&lt;')
.replace(/ /g,'&nbsp;')
.replace(/\n/g,'')
},
updatePrompt: function(el) { updatePrompt: function(el) {
// i WEEEPPPPPPpppppppppppp that this reflow takes so long. it adds this // i WEEEPPPPPPpppppppppppp that this reflow takes so long. it adds this
// super annoying delay to every keystroke... I have tried everything // super annoying delay to every keystroke... I have tried everything
@ -59,7 +72,7 @@ var CommandPromptView = Backbone.View.extend({
// well... // well...
var val = el.value; var val = el.value;
this.commandSpan.innerText = val; this.commandSpan.innerHTML = this.badHtmlEncode(val);
//console.log(val, el.selectionStart, el.selectionEnd); //console.log(val, el.selectionStart, el.selectionEnd);
}, },

View file

@ -259,9 +259,9 @@ p.commandLine span.prompt {
} }
#commandLineBar #commandTextField { #commandLineBar #commandTextField {
position:fixed; position: absolute;
top: 0px; top: -1000px;
left: 0px; left: -1000px;
} }
#commandLineHistory { #commandLineHistory {