@progress/kendo-angular-common
Version:
Kendo UI for Angular - Utility Package
42 lines (41 loc) • 1.42 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { ResizeService } from './resize.service';
const HAS_OBSERVER = typeof ResizeObserver !== 'undefined';
/**
* @hidden
*/
export class ResizeObserverService extends ResizeService {
element;
ngZone;
resizeObserver;
static supported() {
return HAS_OBSERVER;
}
constructor(resizeBatchService, element, ngZone) {
super(resizeBatchService);
this.element = element;
this.ngZone = ngZone;
}
destroy() {
super.destroy();
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
this.parentElement = null;
}
init() {
this.parentElement = this.element.nativeElement.parentElement;
this.initSize();
this.state = 2 /* ServiceState.Initialized */;
this.ngZone.runOutsideAngular(() => {
this.resizeObserver = new ResizeObserver(() => {
this.checkSize();
});
this.resizeObserver.observe(this.parentElement);
});
}
}