From af0259cb8e047f3ca246851d21fe044b4ed35c5b Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Tue, 6 Jan 2015 16:01:41 +0100 Subject: [PATCH] added bounding box to image node style --- dist/vis.js | 15 ++++++++++++--- lib/network/Node.js | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/dist/vis.js b/dist/vis.js index 754bc9bc..fce9b57c 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -26715,7 +26715,16 @@ return /******/ (function(modules) { // webpackBootstrap yLabel = this.y; } + + this.boundingBox.top = this.top; + this.boundingBox.left = this.left; + this.boundingBox.right = this.left + this.width; + this.boundingBox.bottom = this.top + this.height; + this._label(ctx, this.label, this.x, yLabel, undefined, "top"); + 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); }; @@ -27021,9 +27030,9 @@ return /******/ (function(modules) { // webpackBootstrap if (this.label) { this._label(ctx, this.label, this.x, this.y + this.height / 2, undefined, 'top',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) + 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); } }; diff --git a/lib/network/Node.js b/lib/network/Node.js index ba21b2d4..6622870b 100644 --- a/lib/network/Node.js +++ b/lib/network/Node.js @@ -565,7 +565,16 @@ Node.prototype._drawImage = function (ctx) { yLabel = this.y; } + + this.boundingBox.top = this.top; + this.boundingBox.left = this.left; + this.boundingBox.right = this.left + this.width; + this.boundingBox.bottom = this.top + this.height; + this._label(ctx, this.label, this.x, yLabel, undefined, "top"); + 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); }; @@ -871,9 +880,9 @@ Node.prototype._drawShape = function (ctx, shape) { if (this.label) { this._label(ctx, this.label, this.x, this.y + this.height / 2, undefined, 'top',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) + 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); } };