From 01c1a7fc13841d300f0401433dc2b8ebada8666d Mon Sep 17 00:00:00 2001 From: Geert Selderslaghs Date: Tue, 10 Dec 2024 14:09:06 +0100 Subject: [PATCH] enhancement(featureDiscovery) implement initialization on multiple instances #252 --- src/tapTarget.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tapTarget.ts b/src/tapTarget.ts index 7b2fc71edd..337efaee7e 100644 --- a/src/tapTarget.ts +++ b/src/tapTarget.ts @@ -25,6 +25,7 @@ export class TapTarget extends Component implements Openable { */ isOpen: boolean; + static _taptargets: TapTarget[]; private wrapper: HTMLElement; // private _origin: HTMLElement; private originEl: HTMLElement; @@ -48,6 +49,8 @@ export class TapTarget extends Component implements Openable { this._setup(); this._calculatePositioning(); this._setupEventHandlers(); + + TapTarget._taptargets.push(this); } static get defaults(): TapTargetOptions { @@ -82,6 +85,10 @@ export class TapTarget extends Component implements Openable { destroy() { this._removeEventHandlers(); (this.el as any).TapTarget = undefined; + const index = TapTarget._taptargets.indexOf(this); + if (index >= 0) { + TapTarget._taptargets.splice(index, 1); + } } _setupEventHandlers() { @@ -289,4 +296,8 @@ export class TapTarget extends Component implements Openable { document.body.removeEventListener('keypress', this._handleDocumentClick, true); document.body.removeEventListener('touchend', this._handleDocumentClick); }; + + static { + TapTarget._taptargets = []; + } }