Skip to content

Commit 2ee7903

Browse files
committed
refactor(button): unsubscribe from animationFrameScheduler on destroy
1 parent 13513b7 commit 2ee7903

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

projects/igniteui-angular/src/lib/directives/button/button-base.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import {
99
booleanAttribute,
1010
inject,
1111
AfterViewInit,
12+
OnDestroy
1213
} from '@angular/core';
1314
import { PlatformUtil } from '../../core/utils';
14-
import { animationFrameScheduler } from 'rxjs';
15+
import { animationFrameScheduler, Subscription } from 'rxjs';
1516

1617
export const IgxBaseButtonType = {
1718
Flat: 'flat',
@@ -21,9 +22,10 @@ export const IgxBaseButtonType = {
2122

2223

2324
@Directive()
24-
export abstract class IgxButtonBaseDirective implements AfterViewInit{
25+
export abstract class IgxButtonBaseDirective implements AfterViewInit, OnDestroy {
2526
private _platformUtil = inject(PlatformUtil);
2627
private _viewInit = false;
28+
private _animationScheduler: Subscription;
2729

2830
/**
2931
* Emitted when the button is clicked.
@@ -111,12 +113,16 @@ export abstract class IgxButtonBaseDirective implements AfterViewInit{
111113
if (this._platformUtil.isBrowser && !this._viewInit) {
112114
this._viewInit = true;
113115

114-
animationFrameScheduler.schedule(() => {
116+
this._animationScheduler = animationFrameScheduler.schedule(() => {
115117
this.element.nativeElement.style.removeProperty('--_init-transition');
116118
});
117119
}
118120
}
119121

122+
public ngOnDestroy(): void {
123+
this._animationScheduler.unsubscribe();
124+
}
125+
120126
/**
121127
* @hidden
122128
* @internal

0 commit comments

Comments
 (0)