Skip to content

Commit

Permalink
Dependencies are clone to isolate in case of multiple instances + Fix…
Browse files Browse the repository at this point in the history
… typescript errors.
  • Loading branch information
javdome committed Jan 17, 2024
1 parent bb01404 commit 378a145
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions arrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*
* Class to easily draw lines to connect items in the vis Timeline module.
*
* @version 4.3.1
* @date 2024-01-16
* @version 4.3.2
* @date 2024-01-17
*
* @copyright (c) Javi Domenech ([email protected])
*
Expand Down Expand Up @@ -85,7 +85,7 @@ export default class Arrow {
"path"
);

this._dependency = dependencies;
this._dependency = [...dependencies];

/** @private @type {SVGPathElement[]} */
this._dependencyPath = [];
Expand Down Expand Up @@ -171,16 +171,17 @@ export default class Arrow {

//Checks if at least one item is visible in screen
let oneItemVisible = false; //Iniciamos a false
//Checks if the groups of items are both visible
let groupOf_1_isVisible = false; //Iniciamos a false
let groupOf_2_isVisible = false; //Iniciamos a false
if (bothItemsExist) {
const visibleItems = this._timeline.getVisibleItems();
for (let k = 0; k < visibleItems.length ; k++) {
if (dep.id_item_1 == visibleItems[k]) oneItemVisible = true;
if (dep.id_item_2 == visibleItems[k]) oneItemVisible = true;
}

//Checks if the groups of items are both visible
var groupOf_1_isVisible = false; //Iniciamos a false
var groupOf_2_isVisible = false; //Iniciamos a false


let groupOf_1 = this._timeline.itemsData.get(dep.id_item_1).group; //let groupOf_1 = items.get(dep.id_item_1).group;

Expand All @@ -193,10 +194,10 @@ export default class Arrow {

// If groups are null then they are not visible.
if (groupOf_1 == null){
var groupOf_1_isVisible = false;
groupOf_1_isVisible = false;
}
if (groupOf_2 == null){
var groupOf_2_isVisible = false;
groupOf_2_isVisible = false;
}
}

Expand Down Expand Up @@ -327,8 +328,9 @@ export default class Arrow {

this._dependency.splice(index, 1); //Elimino del array dependency
this._dependencyPath.splice(index, 1); //Elimino del array dependencyPath

list[index + 1].parentNode.removeChild(list[index + 1]); //Lo elimino del dom

list[index + 1].parentNode?.removeChild(list[index + 1]); //Lo elimino del dom

}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "timeline-arrows",
"version": "4.3.1",
"version": "4.3.2",
"description": "Package to easily draw lines to connect items in the vis Timeline module.",
"main": "arrow.js",
"types": "arrow.d.ts",
Expand Down

0 comments on commit 378a145

Please sign in to comment.