Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

Commit

Permalink
Attach listeners on root instead of body (closes #57)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkon committed Jan 11, 2020
1 parent cbbe8ae commit 40d9c3d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/click-outside.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ export class ClickOutsideDirective implements OnInit, OnChanges, OnDestroy {

private _initClickOutsideListener() {
this._ngZone.runOutsideAngular(() => {
this._events.forEach(e => document.body.addEventListener(e, this._onClickBody));
this._events.forEach(e => document.addEventListener(e, this._onClickBody));
});
}

private _removeClickOutsideListener() {
this._ngZone.runOutsideAngular(() => {
this._events.forEach(e => document.body.removeEventListener(e, this._onClickBody));
this._events.forEach(e => document.removeEventListener(e, this._onClickBody));
});
}

Expand Down

0 comments on commit 40d9c3d

Please sign in to comment.