Skip to content

Commit

Permalink
bugfix(lib): fix visjs#2171 ctxRenderer update for custom shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Marov committed Jul 10, 2024
1 parent df3881d commit de326af
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
28 changes: 25 additions & 3 deletions lib/network/modules/components/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class Node {

/**
* Attach a edge to the node
*
* @param {Edge} edge
*/
attachEdge(edge) {
Expand All @@ -99,6 +100,7 @@ class Node {

/**
* Detach a edge from the node
*
* @param {Edge} edge
*/
detachEdge(edge) {
Expand All @@ -110,6 +112,7 @@ class Node {

/**
* Set or overwrite options for the node
*
* @param {object} options an object with options
* @returns {null|boolean}
*/
Expand Down Expand Up @@ -196,6 +199,7 @@ class Node {
*
* Images are always loaded, even if they are not used in the current shape.
* The user may switch to an image shape later on.
*
* @private
*/
_load_images() {
Expand Down Expand Up @@ -251,6 +255,7 @@ class Node {

/**
* Check that opacity is only between 0 and 1
*
* @param {number} opacity
* @returns {boolean}
*/
Expand All @@ -260,6 +265,7 @@ class Node {

/**
* Check that origin is 'center' or 'top-left'
*
* @param {string} origin
* @returns {boolean}
*/
Expand All @@ -271,9 +277,10 @@ class Node {
* Copy group option values into the node options.
*
* The group options override the global node options, so the copy of group options
* must happen *after* the global node options have been set.
* must happen *after* the global node options have been set.
*
* This method must also be called also if the global node options have changed and the group options did not.
*
* @param {object} parentOptions
* @param {object} newOptions new values for the options, currently only passed in for check
* @param {object} groupList
Expand Down Expand Up @@ -326,10 +333,11 @@ class Node {
/**
* This process all possible shorthands in the new options and makes sure that the parentOptions are fully defined.
* Static so it can also be used by the handler.
*
* @param {object} parentOptions
* @param {object} newOptions
* @param {boolean} [allowDeletion]
* @param {object} [globalOptions]
* @param {boolean} [allowDeletion=false]
* @param {object} [globalOptions={}]
* @param {object} [groupList]
* @static
*/
Expand Down Expand Up @@ -638,6 +646,7 @@ class Node {

/**
* get the title of this node.
*
* @returns {string} title The title of the node, or undefined when no title
* has been set.
*/
Expand All @@ -647,6 +656,7 @@ class Node {

/**
* Calculate the distance to the border of the Node
*
* @param {CanvasRenderingContext2D} ctx
* @param {number} angle Angle in radians
* @returns {number} distance Distance to the border in pixels
Expand All @@ -657,6 +667,7 @@ class Node {

/**
* Check if this node has a fixed x and y position
*
* @returns {boolean} true if fixed, false if not
*/
isFixed() {
Expand All @@ -665,6 +676,7 @@ class Node {

/**
* check if this node is selecte
*
* @returns {boolean} selected True if node is selected, else false
*/
isSelected() {
Expand All @@ -673,6 +685,7 @@ class Node {

/**
* Retrieve the value of the node. Can be undefined
*
* @returns {number} value
*/
getValue() {
Expand All @@ -681,6 +694,7 @@ class Node {

/**
* Get the current dimensions of the label
*
* @returns {rect}
*/
getLabelSize() {
Expand All @@ -690,6 +704,7 @@ class Node {
/**
* Adjust the value range of the node. The node will adjust it's size
* based on its value.
*
* @param {number} min
* @param {number} max
* @param {number} total
Expand Down Expand Up @@ -721,6 +736,7 @@ class Node {
/**
* Draw this node in the given canvas
* The 2d context of a HTML canvas can be retrieved by canvas.getContext("2d");
*
* @param {CanvasRenderingContext2D} ctx
* @returns {object} Callbacks to draw later on higher layers.
*/
Expand All @@ -734,6 +750,7 @@ class Node {

/**
* Update the bounding box of the shape
*
* @param {CanvasRenderingContext2D} ctx
*/
updateBoundingBox(ctx) {
Expand All @@ -743,6 +760,7 @@ class Node {
/**
* Recalculate the size of this node in the given canvas
* The 2d context of a HTML canvas can be retrieved by canvas.getContext("2d");
*
* @param {CanvasRenderingContext2D} ctx
*/
resize(ctx) {
Expand All @@ -753,6 +771,7 @@ class Node {
/**
* Determine all visual elements of this node instance, in which the given
* point falls within the bounding shape.
*
* @param {point} point
* @returns {Array.<nodeClickItem|nodeLabelClickItem>} list with the items which are on the point
*/
Expand All @@ -774,6 +793,7 @@ class Node {

/**
* Check if this object is overlapping with the provided object
*
* @param {object} obj an object with parameters left, top, right, bottom
* @returns {boolean} True if location is located on node
*/
Expand All @@ -788,6 +808,7 @@ class Node {

/**
* Check if this object is overlapping with the provided object
*
* @param {object} obj an object with parameters left, top, right, bottom
* @returns {boolean} True if location is located on node
*/
Expand All @@ -804,6 +825,7 @@ class Node {
* Check valid values for mass
*
* The mass may not be negative or zero. If it is, reset to 1
*
* @param {object} options
* @param {Node.id} id
* @static
Expand Down
1 change: 1 addition & 0 deletions lib/network/modules/components/nodes/shapes/CustomShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ShapeBase from "../util/ShapeBase";

/**
* A CustomShape Node/Cluster shape.
*
* @augments ShapeBase
*/
class CustomShape extends ShapeBase {
Expand Down

0 comments on commit de326af

Please sign in to comment.