Skip to content

Commit

Permalink
enhancement(featureDiscovery) implement initialization on multiple in…
Browse files Browse the repository at this point in the history
…stances #252
  • Loading branch information
gselderslaghs committed Dec 10, 2024
1 parent f2b107d commit 01c1a7f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/tapTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class TapTarget extends Component<TapTargetOptions> implements Openable {
*/
isOpen: boolean;

static _taptargets: TapTarget[];
private wrapper: HTMLElement;
// private _origin: HTMLElement;
private originEl: HTMLElement;
Expand All @@ -48,6 +49,8 @@ export class TapTarget extends Component<TapTargetOptions> implements Openable {
this._setup();
this._calculatePositioning();
this._setupEventHandlers();

TapTarget._taptargets.push(this);
}

static get defaults(): TapTargetOptions {
Expand Down Expand Up @@ -82,6 +85,10 @@ export class TapTarget extends Component<TapTargetOptions> 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() {
Expand Down Expand Up @@ -289,4 +296,8 @@ export class TapTarget extends Component<TapTargetOptions> implements Openable {
document.body.removeEventListener('keypress', this._handleDocumentClick, true);
document.body.removeEventListener('touchend', this._handleDocumentClick);
};

static {
TapTarget._taptargets = [];
}
}

0 comments on commit 01c1a7f

Please sign in to comment.