From 65accb48dccd3fdc93b001a28d7e4fc8327cb13e Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Tue, 26 Nov 2019 07:52:49 -0800 Subject: [PATCH 1/3] reverted #1047 (updating styles) as it is causing cellheight() to fail (#1068) which is worse and more common than missing animation. --- src/gridstack.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index 636d4f177..db2c48b9f 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -1091,14 +1091,14 @@ maxHeight = this._styles._max; } - if (this._styles._max !== 0 && maxHeight <= this._styles._max) { // Keep this._styles._max increasing - return ; - } this._initStyles(); this._updateContainerHeight(); if (!this.opts.cellHeight) { // The rest will be handled by CSS return ; } + if (this._styles._max !== 0 && maxHeight <= this._styles._max) { // Keep this._styles._max increasing + return ; + } if (!this.opts.verticalMargin || this.opts.cellHeightUnit === this.opts.verticalMarginUnit) { getHeight = function(nbRows, nbMargins) { From 31f35ef31ee12ab94af3b32bd25c2b4655ba353b Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Tue, 26 Nov 2019 08:33:06 -0800 Subject: [PATCH 2/3] test case for #1068 --- doc/CHANGES.md | 3 ++- spec/gridstack-spec.js | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 2da115402..22b559430 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -25,11 +25,12 @@ Change log ## v0.5.3-dev (upcoming changes) +- fix for griditems with x=0 placement wrong order (introduced for #1017) ([#1054](https://github.com/gridstack/gridstack.js/issues/1054)). +- fix `cellHeight(val)` not working due to style change caused by #937 fix ([#1068](https://github.com/gridstack/gridstack.js/issues/1068)). - add `gridstack.poly.js` for IE and older browsers, removed `core-js` lib from samples (<1k vs 85k), and all IE8 mentions ([#1061](https://github.com/gridstack/gridstack.js/pull/1061)). - add `jquery-ui.js` (and min.js) as minimal subset we need (55k vs 248k), which is now part of `gridstack.all.js`. Include individual parts if you need your own lib instead of all.js ([#1064](https://github.com/gridstack/gridstack.js/pull/1064)). - changed jquery dependency to lowest we can use (>=1.8) ([#629](https://github.com/gridstack/gridstack.js/issues/629)). -- fix for griditems with x=0 placement wrong order (introduced for #1017) ([#1054](https://github.com/gridstack/gridstack.js/issues/1054)). ## v0.5.3 (2019-11-20) diff --git a/spec/gridstack-spec.js b/spec/gridstack-spec.js index aac0ad53f..7b320a3a7 100644 --- a/spec/gridstack-spec.js +++ b/spec/gridstack-spec.js @@ -247,27 +247,27 @@ describe('gridstack', function() { afterEach(function() { document.body.removeChild(document.getElementById('gs-cont')); }); - it('should have no changes', function() { + it('should start at 80 then become 120', function() { var options = { cellHeight: 80, verticalMargin: 10, column: 12 }; $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); + var container = $('.grid-stack'); + var grid = container.data('gridstack'); + var rows = container.attr('data-gs-current-height'); + + expect(grid.cellHeight()).toBe(80); + expect(parseInt(container.css('height'))).toBe(rows * 80 + (rows-1) * 10); + grid.cellHeight( grid.cellHeight() ); expect(grid.cellHeight()).toBe(80); - }); - it('should change cellHeight to 120', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - column: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); + expect(parseInt(container.css('height'))).toBe(rows * 80 + (rows-1) * 10); + grid.cellHeight( 120 ); expect(grid.cellHeight()).toBe(120); + expect(parseInt(container.css('height'))).toBe(rows * 120 + (rows-1) * 10); }); }); From 47c5a3241ce8492e8016fa98d2e4b35dd16d68ae Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Tue, 26 Nov 2019 08:41:46 -0800 Subject: [PATCH 3/3] tweaks to cellHeight() tests --- spec/gridstack-spec.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/spec/gridstack-spec.js b/spec/gridstack-spec.js index 7b320a3a7..13c3c497c 100644 --- a/spec/gridstack-spec.js +++ b/spec/gridstack-spec.js @@ -248,9 +248,11 @@ describe('gridstack', function() { document.body.removeChild(document.getElementById('gs-cont')); }); it('should start at 80 then become 120', function() { + var cellHeight = 80; + var verticalMargin = 10; var options = { - cellHeight: 80, - verticalMargin: 10, + cellHeight: cellHeight, + verticalMargin: verticalMargin, column: 12 }; $('.grid-stack').gridstack(options); @@ -258,16 +260,22 @@ describe('gridstack', function() { var grid = container.data('gridstack'); var rows = container.attr('data-gs-current-height'); - expect(grid.cellHeight()).toBe(80); - expect(parseInt(container.css('height'))).toBe(rows * 80 + (rows-1) * 10); + expect(grid.cellHeight()).toBe(cellHeight); + expect(parseInt(container.css('height'))).toBe(rows * cellHeight + (rows-1) * verticalMargin); + + grid.cellHeight( grid.cellHeight() ); // should be no-op + expect(grid.cellHeight()).toBe(cellHeight); + expect(parseInt(container.css('height'))).toBe(rows * cellHeight + (rows-1) * verticalMargin); - grid.cellHeight( grid.cellHeight() ); - expect(grid.cellHeight()).toBe(80); - expect(parseInt(container.css('height'))).toBe(rows * 80 + (rows-1) * 10); + cellHeight = 120; // should change and CSS actual height + grid.cellHeight( cellHeight ); + expect(grid.cellHeight()).toBe(cellHeight); + expect(parseInt(container.css('height'))).toBe(rows * cellHeight + (rows-1) * verticalMargin); - grid.cellHeight( 120 ); - expect(grid.cellHeight()).toBe(120); - expect(parseInt(container.css('height'))).toBe(rows * 120 + (rows-1) * 10); + cellHeight = 20; // should change and CSS actual height + grid.cellHeight( cellHeight ); + expect(grid.cellHeight()).toBe(cellHeight); + expect(parseInt(container.css('height'))).toBe(rows * cellHeight + (rows-1) * verticalMargin); }); });