Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ import { translateXY } from '../../utils/translate';
}
})
export class DataTableBodyComponent implements OnInit, OnDestroy {
static _timeOutID: any;
@Input() scrollbarV: boolean;
@Input() scrollbarH: boolean;
@Input() loadingIndicator: boolean;
Expand Down Expand Up @@ -327,6 +328,7 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
if (this.rowDetail || this.groupHeader) {
this.listener.unsubscribe();
}
clearTimeout(DataTableBodyComponent._timeOutID);
}

/**
Expand Down Expand Up @@ -576,7 +578,7 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
* Hides the loading indicator
*/
hideIndicator(): void {
setTimeout(() => (this.loadingIndicator = false), 500);
DataTableBodyComponent._timeOutID = setTimeout(() => (this.loadingIndicator = false), 500);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { MouseEvent } from '../../events';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ScrollerComponent implements OnInit, OnDestroy {
static _requestID: any;
@Input() scrollbarV: boolean = false;
@Input() scrollbarH: boolean = false;

Expand Down Expand Up @@ -65,6 +66,7 @@ export class ScrollerComponent implements OnInit, OnDestroy {
this.parentElement.removeEventListener('scroll', this._scrollEventListener);
this._scrollEventListener = null;
}
cancelAnimationFrame(ScrollerComponent._requestID);
}

setOffset(offsetY: number): void {
Expand All @@ -75,7 +77,7 @@ export class ScrollerComponent implements OnInit, OnDestroy {

onScrolled(event: MouseEvent): void {
const dom: Element = <Element>event.currentTarget;
requestAnimationFrame(() => {
ScrollerComponent._requestID = requestAnimationFrame(() => {
this.scrollYPos = dom.scrollTop;
this.scrollXPos = dom.scrollLeft;
this.updateOffset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import { sortRows } from '../utils/sort';
}
})
export class DatatableComponent implements OnInit, DoCheck, AfterViewInit {
static _requestID: any;
/**
* Template for the target marker of drag target columns.
*/
Expand Down Expand Up @@ -681,7 +682,7 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit {
return;
}

requestAnimationFrame(() => {
DatatableComponent._requestID = requestAnimationFrame(() => {
this.recalculate();

// emit page for virtual server-side kickoff
Expand Down Expand Up @@ -1135,6 +1136,7 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit {

ngOnDestroy() {
this._subscriptions.forEach(subscription => subscription.unsubscribe());
cancelAnimationFrame(DatatableComponent._requestID);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class OrderableDirective implements AfterContentInit, OnDestroy {
d.dragging.unsubscribe();
d.dragEnd.unsubscribe();
});
this.draggables?.destroy();
}

updateSubscriptions(): void {
Expand Down
12 changes: 9 additions & 3 deletions src/app/basic/live.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ViewChild, ChangeDetectorRef } from '@angular/core';
import { Component, ViewChild, ChangeDetectorRef, OnDestroy, HostListener } from '@angular/core';
import { ColumnMode } from 'projects/swimlane/ngx-datatable/src/public-api';

@Component({
Expand Down Expand Up @@ -40,7 +40,8 @@ import { ColumnMode } from 'projects/swimlane/ngx-datatable/src/public-api';
</div>
`
})
export class LiveDataComponent {
export class LiveDataComponent implements OnDestroy {
static _timeOutID: any;
@ViewChild('mydatatable') mydatatable: any;

count = 50;
Expand Down Expand Up @@ -73,7 +74,7 @@ export class LiveDataComponent {
return;
}

setTimeout(this.updateRandom.bind(this), 50);
LiveDataComponent._timeOutID = setTimeout(this.updateRandom.bind(this), 50);
}

stop(): void {
Expand Down Expand Up @@ -118,4 +119,9 @@ export class LiveDataComponent {

req.send();
}

@HostListener('unloaded')
public ngOnDestroy(): void {
clearTimeout(LiveDataComponent._timeOutID);
}
}