mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 08:28:50 +02:00
font size now adaptive
This commit is contained in:
parent
749108a775
commit
7ab6f26bef
1 changed files with 11 additions and 1 deletions
12
src/tree.js
12
src/tree.js
|
@ -516,6 +516,16 @@ var VisNode = Backbone.Model.extend({
|
|||
this.get('commit').get('parents')[0].get('visNode').toFront();
|
||||
},
|
||||
|
||||
getFontSize: function(str) {
|
||||
if (str.length < 3) {
|
||||
return 12;
|
||||
} else if (str.length < 5) {
|
||||
return 10;
|
||||
} else {
|
||||
return 8;
|
||||
}
|
||||
},
|
||||
|
||||
genGraphics: function(paper) {
|
||||
var pos = this.getScreenCoords();
|
||||
var textPos = this.getTextScreenCoords();
|
||||
|
@ -525,7 +535,7 @@ var VisNode = Backbone.Model.extend({
|
|||
});
|
||||
var text = paper.text(textPos.x, textPos.y, String(this.get('id')));
|
||||
text.attr({
|
||||
'font-size': 12,
|
||||
'font-size': this.getFontSize(this.get('id')),
|
||||
'font-weight': 'bold',
|
||||
'font-family': 'Monaco, Courier, font-monospace',
|
||||
opacity: this.getOpacity()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue