Added remove capability to scatter.(Merged local branch 'scatter')

This commit is contained in:
Severin Opel 2019-07-29 16:16:31 +02:00
commit 0bcf931465

View File

@ -372,6 +372,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)
}
} }
} }
@ -1000,6 +1007,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)
} }