Browse Source

improved (not neccesarily fixed) the fontFill offset between different browsers. #365

v3_develop
Alex de Mulder 10 years ago
parent
commit
08503bd9c4
2 changed files with 26536 additions and 26533 deletions
  1. +26530
    -26528
      dist/vis.js
  2. +6
    -5
      lib/network/Node.js

+ 26530
- 26528
dist/vis.js
File diff suppressed because it is too large
View File


+ 6
- 5
lib/network/Node.js View File

@ -584,7 +584,6 @@ Node.prototype._drawImageAtPosition = function (ctx) {
Node.prototype._drawImageLabel = function (ctx) {
var yLabel;
if (this.imageObj.width != 0 ) {
yLabel = this.y + this.height / 2;
}
else {
@ -592,7 +591,7 @@ Node.prototype._drawImageLabel = function (ctx) {
yLabel = this.y;
}
this._label(ctx, this.label, this.x, yLabel, undefined, "top");
this._label(ctx, this.label, this.x, yLabel, undefined, 'hanging');
};
Node.prototype._drawImage = function (ctx) {
@ -955,7 +954,7 @@ Node.prototype._drawShape = function (ctx, shape) {
this.boundingBox.bottom = this.y + this.options.radius;
if (this.label) {
this._label(ctx, this.label, this.x, this.y + this.height / 2, undefined, 'top',true);
this._label(ctx, this.label, this.x, this.y + this.height / 2, undefined, 'hanging',true);
this.boundingBox.left = Math.min(this.boundingBox.left, this.labelDimensions.left);
this.boundingBox.right = Math.max(this.boundingBox.right, this.labelDimensions.left + this.labelDimensions.width);
this.boundingBox.bottom = Math.max(this.boundingBox.bottom, this.boundingBox.bottom + this.labelDimensions.height);
@ -997,7 +996,7 @@ Node.prototype._label = function (ctx, text, x, y, align, baseline, labelUnderNo
var lines = text.split('\n');
var lineCount = lines.length;
var fontSize = (Number(this.options.fontSize) + 4); // TODO: why is this +4 ?
var fontSize = Number(this.options.fontSize);
var yLine = y + (1 - lineCount) / 2 * fontSize;
if (labelUnderNode == true) {
yLine = y + (1 - lineCount) / (2 * fontSize);
@ -1012,8 +1011,10 @@ Node.prototype._label = function (ctx, text, x, y, align, baseline, labelUnderNo
var height = this.options.fontSize * lineCount;
var left = x - width / 2;
var top = y - height / 2;
if (baseline == "top") {
if (baseline == "hanging") {
top += 0.5 * fontSize;
top += 3; // distance from node, required because we use hanging. Hanging has less difference between browsers
yLine += 3; // distance from node
}
this.labelDimensions = {top:top,left:left,width:width,height:height,yLine:yLine};

Loading…
Cancel
Save