From 5e98640ded09347be116f7ddda021e4041565fe3 Mon Sep 17 00:00:00 2001 From: Severin Opel Date: Mon, 29 Jul 2019 14:36:00 +0200 Subject: [PATCH] Added a remove function for the DOMScatterContainer. Is automatically called onClose. --- lib/scatter.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/scatter.js b/lib/scatter.js index 1b19fa4..c691da3 100644 --- a/lib/scatter.js +++ b/lib/scatter.js @@ -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) }