Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghislain Beaulac authored and Ghislain Beaulac committed Oct 16, 2017
2 parents ef551d4 + 19cfe6c commit 076ccd6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/services/resizer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ export class ResizerService {

// -- 2nd attach a trigger on the Window DOM element, so that it happens also when resizing after first load
// -- attach auto-resize to Window object only if it exist
$(window).on('resize', () => {
$(window).on('resize.grid', () => {
this.resizeGrid(grid, gridOptions);
});

// destroy the resizer on route change
this.router.events.subscribe((event: NavigationEnd) => {
$(window).trigger('resize').off('resize');
this.destroy();
});
}

Expand Down Expand Up @@ -72,6 +72,13 @@ export class ResizerService {
};
}

/**
* Destroy function when element is destroyed
*/
destroy() {
$(window).trigger('resize.grid').off('resize');
}

/** Resize the datagrid to fit the browser height & width */
resizeGrid(grid: any, gridOptions: GridOption, newSizes?: { height: number, width: number}): void {
// calculate new available sizes but with minimum height of 220px
Expand Down

0 comments on commit 076ccd6

Please sign in to comment.