Skip to content

Commit 5aa79c3

Browse files
authored
removeArrow(id)
1 parent c54e55e commit 5aa79c3

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

arrow.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -403,19 +403,21 @@ export default class Arrow {
403403
* Función que recibe el id de una flecha y la elimina.
404404
* @param {ArrowIdType} id arrow id
405405
*/
406-
removeArrow(id) {
406+
removeArrow(id) {
407407
const index = this._dependency.findIndex(dep => dep.id === id);
408408

409409
if (index >= 0) {
410+
// Get the path element from our specific array before modifying the arrays
411+
const pathToRemove = this._dependencyPath[index];
410412

411-
//var list = document.getElementsByTagName("path"); //FALTA QUE ESTA SELECCION LA HAGA PARA EL DOM DEL TIMELINE INSTANCIADO!!!!
412-
const list = document.querySelectorAll("#" + this._timeline.dom.container.id + " path");
413+
// Remove the SVG element from the DOM
414+
if (pathToRemove && pathToRemove.parentNode) {
415+
pathToRemove.parentNode.removeChild(pathToRemove);
416+
}
413417

414-
this._dependency.splice(index, 1); //Elimino del array dependency
415-
this._dependencyPath.splice(index, 1); //Elimino del array dependencyPath
416-
417-
list[index + 1].parentNode?.removeChild(list[index + 1]); //Lo elimino del dom
418-
418+
// Now, remove the arrow from internal arrays
419+
this._dependency.splice(index, 1);
420+
this._dependencyPath.splice(index, 1);
419421
}
420422
}
421423

@@ -462,4 +464,4 @@ export default class Arrow {
462464
this.removeItemArrows(id);
463465
}
464466

465-
}
467+
}

0 commit comments

Comments
 (0)