Skip to content

Commit

Permalink
Added method removeArrowsBetweenItems
Browse files Browse the repository at this point in the history
  • Loading branch information
javdome committed Feb 5, 2024
1 parent 378a145 commit c1c1f6e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ For instance:
myArrow.removeItemArrows( 23 );
```

**removeArrowsBetweenItems (*itemId1, itemId2*)** Removes the arrows between item 1 and item 2.

For instance:

```javascript
myArrow.removeArrowsBetweenItems( 3, 8);
```

## Examples

You can see some working examples here:
Expand Down
21 changes: 19 additions & 2 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.2
* @date 2024-01-17
* @version 4.4.0
* @date 2024-02-3
*
* @copyright (c) Javi Domenech (javdome@gmail.com)
*
Expand Down Expand Up @@ -352,6 +352,23 @@ export default class Arrow {
return listOfRemovedArrows;
}

/**
* Removes the arrows between item 1 and item 2.
* @param {VisIdType} itemId1 item id
* @param {VisIdType} itemId2 item id
* @returns {(ArrowIdType)[]} id of the removed arrow
*/
removeArrowsBetweenItems(itemId1, itemId2) {
let listOfRemovedArrows = [];
let ArrowsToDelete = this._dependency.filter(dep => (dep.id_item_1 == itemId1 && dep.id_item_2 == itemId2) )
ArrowsToDelete.forEach(dep => {
listOfRemovedArrows.push(dep.id);
this.removeArrow(dep.id)
})
return listOfRemovedArrows
}


/**
* For backward compatibility
* @deprecated use the removeItemArrows method instead.
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.2",
"version": "4.4.0",
"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 c1c1f6e

Please sign in to comment.