diff --git a/projects/ngx-datatable/src/lib/components/datatable.component.ts b/projects/ngx-datatable/src/lib/components/datatable.component.ts index 14cecc372..8b4097603 100644 --- a/projects/ngx-datatable/src/lib/components/datatable.component.ts +++ b/projects/ngx-datatable/src/lib/components/datatable.component.ts @@ -41,7 +41,6 @@ import { DataTableBodyComponent } from './body/body.component'; import { DataTableHeaderComponent } from './header/header.component'; import { ScrollbarHelper } from '../services/scrollbar-helper.service'; import { ColumnChangesService } from '../services/column-changes.service'; -import { DimensionsHelper } from '../services/dimensions-helper.service'; import { throttleable } from '../utils/throttle'; import { adjustColumnWidths, forceFillColumnWidths } from '../utils/math'; import { sortGroupedRows, sortRows } from '../utils/sort'; @@ -84,7 +83,8 @@ import { ProgressBarComponent } from './body/progress-bar.component'; { provide: DatatableComponentToken, useExisting: DatatableComponent - } + }, + ColumnChangesService ], standalone: true, imports: [ @@ -100,7 +100,6 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit, AfterContentInit, OnDestroy { private scrollbarHelper = inject(ScrollbarHelper); - private dimensionsHelper = inject(DimensionsHelper); private cd = inject(ChangeDetectorRef); private columnChangesService = inject(ColumnChangesService); private configuration = inject('configuration' as any, { optional: true }); @@ -961,7 +960,7 @@ export class DatatableComponent * */ recalculateDims(): void { - const dims = this.dimensionsHelper.getDimensions(this.element); + const dims = this.element.getBoundingClientRect(); this._innerWidth = Math.floor(dims.width); if (this.scrollbarV) { diff --git a/projects/ngx-datatable/src/lib/ngx-datatable.module.ts b/projects/ngx-datatable/src/lib/ngx-datatable.module.ts index 8d6ea2542..4d22bbf5f 100644 --- a/projects/ngx-datatable/src/lib/ngx-datatable.module.ts +++ b/projects/ngx-datatable/src/lib/ngx-datatable.module.ts @@ -1,7 +1,4 @@ import { ModuleWithProviders, NgModule } from '@angular/core'; -import { ScrollbarHelper } from './services/scrollbar-helper.service'; -import { DimensionsHelper } from './services/dimensions-helper.service'; -import { ColumnChangesService } from './services/column-changes.service'; import { DataTableFooterTemplateDirective } from './components/footer/footer-template.directive'; import { DatatableComponent } from './components/datatable.component'; import { DataTableColumnDirective } from './components/columns/column.directive'; @@ -40,7 +37,6 @@ import { DatatableRowDefComponent, DatatableRowDefDirective ], - providers: [ScrollbarHelper, DimensionsHelper, ColumnChangesService], exports: [ DatatableComponent, DatatableRowDetailDirective, diff --git a/projects/ngx-datatable/src/lib/services/dimensions-helper.service.ts b/projects/ngx-datatable/src/lib/services/dimensions-helper.service.ts deleted file mode 100644 index d3f97c81b..000000000 --- a/projects/ngx-datatable/src/lib/services/dimensions-helper.service.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Injectable } from '@angular/core'; - -/** - * Gets the width of the scrollbar. Nesc for windows - * http://stackoverflow.com/a/13382873/888165 - */ -@Injectable() -export class DimensionsHelper { - getDimensions(element: Element): ClientRect { - return element.getBoundingClientRect(); - } -} diff --git a/projects/ngx-datatable/src/lib/services/scrollbar-helper.service.ts b/projects/ngx-datatable/src/lib/services/scrollbar-helper.service.ts index a0984ea17..25446d1cf 100644 --- a/projects/ngx-datatable/src/lib/services/scrollbar-helper.service.ts +++ b/projects/ngx-datatable/src/lib/services/scrollbar-helper.service.ts @@ -5,7 +5,7 @@ import { DOCUMENT } from '@angular/common'; * Gets the width of the scrollbar. Nesc for windows * http://stackoverflow.com/a/13382873/888165 */ -@Injectable() +@Injectable({ providedIn: 'root' }) export class ScrollbarHelper { private document = inject(DOCUMENT); diff --git a/projects/ngx-datatable/src/public-api.ts b/projects/ngx-datatable/src/public-api.ts index d46426615..b96833789 100644 --- a/projects/ngx-datatable/src/public-api.ts +++ b/projects/ngx-datatable/src/public-api.ts @@ -40,7 +40,6 @@ export * from './lib/directives/disable-row.directive'; // services export * from './lib/services/scrollbar-helper.service'; -export * from './lib/services/dimensions-helper.service'; export * from './lib/services/column-changes.service'; // types