Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy animation players and clean resources #10267

Merged
merged 6 commits into from
Oct 21, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(overlay): destroy animation players and clean resources, #8450
  • Loading branch information
wnvko committed Oct 11, 2021
commit a7348fe5e4b96f99a27970ccb8b500aa3c65ca4a
Original file line number Diff line number Diff line change
@@ -322,7 +322,7 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
if (this.navigationService && this.id) {
this.navigationService.remove(this.id);
}
if (!this.collapsed && this._overlayId) {
if (this._overlayId) {
this.overlayService.detach(this._overlayId);
}
this.unsubscribe();
22 changes: 18 additions & 4 deletions projects/igniteui-angular/src/lib/services/overlay/overlay.ts
Original file line number Diff line number Diff line change
@@ -659,15 +659,14 @@ export class IgxOverlayService implements OnDestroy {
if (info.componentRef) {
this._appRef.detachView(info.componentRef.hostView);
info.componentRef.destroy();
delete info.componentRef;
}
if (info.hook) {
info.hook.parentElement.insertBefore(info.elementRef.nativeElement, info.hook);
info.hook.parentElement.removeChild(info.hook);
delete info.hook;
}
if (info.wrapperElement) {
delete info.wrapperElement;
}

const index = this._overlayInfos.indexOf(info);
this._overlayInfos.splice(index, 1);

@@ -679,6 +678,20 @@ export class IgxOverlayService implements OnDestroy {
}
this.removeCloseOnEscapeListener();
}

// clean all the resources attached to info
delete info.elementRef;
delete info.settings;
delete info.initialSize;
info.openAnimationPlayer?.destroy();
delete info.openAnimationPlayer;
delete info.openAnimationInnerPlayer;
info.closeAnimationPlayer?.destroy();
delete info.closeAnimationPlayer;
delete info.closeAnimationInnerPlayer;
delete info.ngZone;
delete info.wrapperElement;
info = null;
}

private playOpenAnimation(info: OverlayInfo) {
@@ -942,7 +955,6 @@ export class IgxOverlayService implements OnDestroy {
}

private closeAnimationDone(info: OverlayInfo) {
this.closeDone(info);
if (info.closeAnimationPlayer) {
info.closeAnimationPlayer.reset();
// calling reset does not change hasStarted to false. This is why we are doing it here via internal field
@@ -956,6 +968,8 @@ export class IgxOverlayService implements OnDestroy {
// calling reset does not change hasStarted to false. This is why we are doing it here via internal field
(info.openAnimationPlayer as any)._started = false;
}
// call this last. closeDone will emit this.closed where everything should be cleared
this.closeDone(info);
}

private finishAnimations(info: OverlayInfo) {