diff --git a/examples/network/edgeStyles/selfReference.html b/examples/network/edgeStyles/selfReference.html index ed8902ac69..8c05ecbce8 100644 --- a/examples/network/edgeStyles/selfReference.html +++ b/examples/network/edgeStyles/selfReference.html @@ -77,7 +77,7 @@ from: 2, to: 2, label: "Testing", arrows: 'to, middle, from', selfReference: { size: 40, - angle: Math.PI / 6, + angle: Math.PI * 7 / 6, renderBehindTheNode: false } }, @@ -98,7 +98,18 @@ edges: edges }; var options = { - + edges: { + color: { + color: "#2B7CE9", + highlight: "#2B7CE9", + hover: "#2B7CE9" + }, + hoverWidth: function (width) { return width + 2; }, + shadow: true + }, + interaction: { + hover: true, + }, }; var network = new vis.Network(container, data, options); diff --git a/lib/network/modules/components/nodes/shapes/Box.js b/lib/network/modules/components/nodes/shapes/Box.js index 66565b8cf2..7de47bcc4d 100644 --- a/lib/network/modules/components/nodes/shapes/Box.js +++ b/lib/network/modules/components/nodes/shapes/Box.js @@ -80,7 +80,9 @@ class Box extends NodeBase { * @returns {number} */ distanceToBorder(ctx, angle) { - this.resize(ctx); + if (ctx) { + this.resize(ctx); + } let borderWidth = this.options.borderWidth; return Math.min( diff --git a/lib/network/modules/components/nodes/shapes/Circle.js b/lib/network/modules/components/nodes/shapes/Circle.js index 643b57e421..4c8afc82fe 100644 --- a/lib/network/modules/components/nodes/shapes/Circle.js +++ b/lib/network/modules/components/nodes/shapes/Circle.js @@ -78,7 +78,9 @@ class Circle extends CircleImageBase { * @returns {number} */ distanceToBorder(ctx, angle) { // eslint-disable-line no-unused-vars - this.resize(ctx); + if (ctx) { + this.resize(ctx); + } return this.width * 0.5; } } diff --git a/lib/network/modules/components/nodes/shapes/CircularImage.js b/lib/network/modules/components/nodes/shapes/CircularImage.js index 04b719ca04..a4b665c820 100644 --- a/lib/network/modules/components/nodes/shapes/CircularImage.js +++ b/lib/network/modules/components/nodes/shapes/CircularImage.js @@ -104,7 +104,9 @@ class CircularImage extends CircleImageBase { * @returns {number} */ distanceToBorder(ctx, angle) { // eslint-disable-line no-unused-vars - this.resize(ctx); + if (ctx) { + this.resize(ctx); + } return this.width * 0.5; } } diff --git a/lib/network/modules/components/nodes/shapes/Dot.js b/lib/network/modules/components/nodes/shapes/Dot.js index 1cde7813ee..070ddcf071 100644 --- a/lib/network/modules/components/nodes/shapes/Dot.js +++ b/lib/network/modules/components/nodes/shapes/Dot.js @@ -37,7 +37,9 @@ class Dot extends ShapeBase { * @returns {number} */ distanceToBorder(ctx, angle) { // eslint-disable-line no-unused-vars - this.resize(ctx); + if (ctx) { + this.resize(ctx); + } return this.options.size; } } diff --git a/lib/network/modules/components/nodes/shapes/Ellipse.js b/lib/network/modules/components/nodes/shapes/Ellipse.js index a6e8f59e90..93af9e960a 100644 --- a/lib/network/modules/components/nodes/shapes/Ellipse.js +++ b/lib/network/modules/components/nodes/shapes/Ellipse.js @@ -63,7 +63,9 @@ class Ellipse extends NodeBase { * @returns {number} */ distanceToBorder(ctx, angle) { - this.resize(ctx); + if (ctx) { + this.resize(ctx); + } var a = this.width * 0.5; var b = this.height * 0.5; var w = (Math.sin(angle) * a); diff --git a/lib/network/modules/components/nodes/util/NodeBase.js b/lib/network/modules/components/nodes/util/NodeBase.js index 4217c4f359..2ac9234724 100644 --- a/lib/network/modules/components/nodes/util/NodeBase.js +++ b/lib/network/modules/components/nodes/util/NodeBase.js @@ -61,7 +61,9 @@ class NodeBase { */ _distanceToBorder(ctx,angle) { var borderWidth = this.options.borderWidth; - this.resize(ctx); + if (ctx){ + this.resize(ctx); + } return Math.min( Math.abs(this.width / 2 / Math.cos(angle)), Math.abs(this.height / 2 / Math.sin(angle))) + borderWidth; diff --git a/lib/network/modules/components/shared/ComponentUtil.js b/lib/network/modules/components/shared/ComponentUtil.js index 43b2f7b96d..7e8920a12b 100644 --- a/lib/network/modules/components/shared/ComponentUtil.js +++ b/lib/network/modules/components/shared/ComponentUtil.js @@ -128,7 +128,7 @@ class ComponentUtil { let x = node.x; let y = node.y; - if(ctx && typeof node.distanceToBorder === "function"){ + if(typeof node.distanceToBorder === "function"){ //calculating opposite and adjacent //distaneToBorder becomes Hypotenuse. //Formulas sin(a) = Opposite / Hypotenuse and cos(a) = Adjacent / Hypotenuse diff --git a/test/edges/bezier-edge-dynamic.test.ts b/test/edges/bezier-edge-dynamic.test.ts index 6d411b2cac..63473720e5 100644 --- a/test/edges/bezier-edge-dynamic.test.ts +++ b/test/edges/bezier-edge-dynamic.test.ts @@ -250,8 +250,8 @@ describe('BezierEdgeDynamic', function(): void { ) expect(edge.getPoint(0.5)).to.deep.equal({ - x: 421, - y: -404, + x: 400, + y: -846, }) }) })