Browse Source

Added a remove function for the DOMScatterContainer. Is automatically called onClose.

obersalzberg
Severin Opel 1 year ago
parent
commit
5e98640ded
1 changed files with 25 additions and 0 deletions
  1. +25
    -0
      lib/scatter.js

+ 25
- 0
lib/scatter.js View File

@ -355,6 +355,13 @@ export class AbstractScatter extends Throwable {
close() {
if (this.onClose) {
this.onClose.forEach(callback => callback(this))
/**
Removes self from container when it's closed.
*/
if(this.container){
this.container.remove(this)
}
}
}
@ -960,6 +967,24 @@ export class DOMScatterContainer {
}
}
/**
* Removes an element from the scatter.
*
* @param {Scatter} scatter - Element to remove.
* @memberof DOMScatterContainer
*/
remove(scatter){
this.scatter.delete(scatter.element)
}
/**
* Adds an element to the ScatterContainer.
*
* @param {Scatter} scatter - Element to add to the ScatterContainer.
* @memberof DOMScatterContainer
*/
add(scatter) {
this.scatter.set(scatter.element, scatter)
}

Loading…
Cancel
Save