diff --git a/README.md b/README.md index 0010c60..daa6249 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/arrow.js b/arrow.js index 3cc2b41..93aee79 100644 --- a/arrow.js +++ b/arrow.js @@ -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) * @@ -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. diff --git a/package.json b/package.json index b852c85..c1b559d 100644 --- a/package.json +++ b/package.json @@ -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",