Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions projects/igniteui-angular/src/lib/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ export const SUPPORTED_KEYS = new Set([...Array.from(NAVIGATION_KEYS), 'tab', 'e
* @internal
*
* Creates a new ResizeObserver on `target` and returns it as an Observable.
* Run the resizeObservable outside angular zone, because it patches the MutationObserver which causes an infinite loop.
* Related issue: https://github.com/angular/angular/issues/31712
*/
export function resizeObservable(target: HTMLElement): Observable<ResizeObserverEntry[]> {
return new Observable((observer) => {
Expand Down
18 changes: 11 additions & 7 deletions projects/igniteui-angular/src/lib/slider/slider.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
ViewChildren,
QueryList,
ChangeDetectorRef,
OnChanges
OnChanges,
NgZone
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
import { EditorProvider } from '../core/edit-provider';
Expand Down Expand Up @@ -771,7 +772,8 @@ export class IgxSliderComponent implements
constructor(
private renderer: Renderer2,
private _el: ElementRef,
private _cdr: ChangeDetectorRef) { }
private _cdr: ChangeDetectorRef,
private _ngZone: NgZone) { }

/**
* @hidden
Expand Down Expand Up @@ -1005,11 +1007,13 @@ export class IgxSliderComponent implements
this.positionHandler(null, labelFrom, this.lowerValue);
});

resizeObservable(this._el.nativeElement).pipe(
throttleTime(40),
takeUntil(this._destroyer$)).subscribe(() => {
this.stepDistance = this.calculateStepDistance();
});
this._ngZone.runOutsideAngular(() => {
resizeObservable(this._el.nativeElement).pipe(
throttleTime(40),
takeUntil(this._destroyer$)).subscribe(() => this._ngZone.run( () => {
this.stepDistance = this.calculateStepDistance();
}));
});
}

/**
Expand Down