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

This commit is contained in:
Severin Opel 2019-07-29 14:36:00 +02:00
parent d04f92ee7f
commit 5e98640ded

View File

@ -355,6 +355,13 @@ export class AbstractScatter extends Throwable {
close() { close() {
if (this.onClose) { if (this.onClose) {
this.onClose.forEach(callback => callback(this)) 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) { add(scatter) {
this.scatter.set(scatter.element, scatter) this.scatter.set(scatter.element, scatter)
} }