From ab419e1db64eb57de4fc422006043382cb1958e6 Mon Sep 17 00:00:00 2001 From: radiolips Date: Sun, 17 Nov 2019 09:09:41 -0500 Subject: [PATCH] Fix #937 Fixes #937. Styles were being removed and recreated on every widget drag. This could have had other unexpect impacts as well. Should make moving widgets faster. --- doc/CHANGES.md | 1 + src/gridstack.js | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 5bf1d19bc..e69f97196 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -24,6 +24,7 @@ Change log ## v0.5.2-dev (upcoming changes) +- fix widgets not animating when animate: true is used. on every move, styles were recreated-fix should slightly improve gridstack.js speed ([#937](https://github.com/gridstack/gridstack.js/issues/937)). - fix moving widgets when having multiple grids. jquery-ui workaround ([#1043](https://github.com/gridstack/gridstack.js/issues/1043)). - switch to eslint ([#763](https://github.com/gridstack/gridstack.js/issues/763)). - null values to addWidget() exception fix ([#1042](https://github.com/gridstack/gridstack.js/issues/1042)). diff --git a/src/gridstack.js b/src/gridstack.js index ac1e06074..10b09adc1 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -1094,14 +1094,15 @@ if (typeof maxHeight == 'undefined') { 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) {