Skip to content

Commit

Permalink
fix(grid): Resizer on 1st grid stop working after 2nd grid is created
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed May 19, 2018
1 parent c58e788 commit ed462ca
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export class ResizerService {
return (this._grid && this._grid.getOptions) ? this._grid.getOptions() : {};
}

/** Getter for retrieving the Grid UID that is used when dealing with multiple grids in same view. */
private get _gridUid(): string {
return (this._grid && this._grid.getUID) ? this._grid.getUID() : this._gridOptions.gridId;
}

init(grid: any): void {
this._grid = grid;
this.aureliaEventPrefix = (this._gridOptions && this._gridOptions.defaultAureliaEventPrefix) ? this._gridOptions.defaultAureliaEventPrefix : 'asg';
Expand All @@ -50,7 +55,7 @@ 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.grid', () => {
$(window).on(`resize.grid.${this._gridUid}`, () => {
this.ea.publish(`${this.aureliaEventPrefix}:onBeforeResize`, true);
// for some yet unknown reason, calling the resize twice removes any stuttering/flickering when changing the height and makes it much smoother
this.resizeGrid(0, newSizes);
Expand Down Expand Up @@ -104,7 +109,7 @@ export class ResizerService {
* Dispose function when element is destroyed
*/
dispose() {
$(window).off('resize.grid');
$(window).off(`resize.grid.${this._gridUid}`);
}

getLastResizeDimensions(): GridDimension {
Expand Down

0 comments on commit ed462ca

Please sign in to comment.