Skip to content

Commit

Permalink
Refactor #12031 - Add two-way binding to visible option
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Nov 4, 2022
1 parent e397612 commit 6ce9c94
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/components/overlay/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export class Overlay implements OnDestroy {
this._options = val;
}

@Output() visibleChange: EventEmitter<any> = new EventEmitter();

@Output() onBeforeShow: EventEmitter<any> = new EventEmitter();

@Output() onShow: EventEmitter<any> = new EventEmitter();
Expand Down Expand Up @@ -252,21 +254,26 @@ export class Overlay implements OnDestroy {
}

show(overlay?: HTMLElement, isFocus: boolean = false) {
this.visible = true;
this.onVisibleChange(true);
this.handleEvents('onShow', { overlay: overlay || this.overlayEl, target: this.targetEl, mode: this.overlayMode });

isFocus && DomHandler.focus(this.targetEl);
this.modal && DomHandler.addClass(this.document?.body, 'p-overflow-hidden');
}

hide(overlay?: HTMLElement, isFocus: boolean = false) {
this.visible = false;
this.onVisibleChange(false);
this.handleEvents('onHide', { overlay: overlay || this.overlayEl, target: this.targetEl, mode: this.overlayMode });

isFocus && DomHandler.focus(this.targetEl);
this.modal && DomHandler.removeClass(this.document?.body, 'p-overflow-hidden');
}

onVisibleChange(visible: boolean) {
this._visible = visible;
this.visibleChange.emit(visible);
}

alignOverlay() {
!this.modal && DomHandler.alignOverlay(this.overlayEl, this.targetEl, this.appendTo);
}
Expand Down

0 comments on commit 6ce9c94

Please sign in to comment.