Skip to content

Commit ae50644

Browse files
author
Alain Dumesny
committed
oneColumnMode bug fix
* window resize only need to restor back to non oneColumn if we auto went into 1 column (as opposed to user calling setColumn(1) in a large window) * this was causing column.html editing in 1 column to jump back to 12. * introduced by my last change #1120
1 parent 4412528 commit ae50644

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/gridstack.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@
666666

667667
var GridStack = function(el, opts) {
668668
var self = this;
669-
var _prevColumn, isAutoCellHeight;
669+
var oneColumnAutoMode, _prevColumn, isAutoCellHeight;
670670

671671
opts = opts || {};
672672

@@ -823,17 +823,19 @@
823823
self._updateHeightsOnResize();
824824
}
825825

826-
var oneColumnWidth = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) <= self.opts.minWidth;
826+
if (self.opts.staticGrid) { return; }
827827

828-
if (oneColumnWidth && !self.opts.disableOneColumnMode) {
829-
if (self._prevColumn || self.opts.staticGrid) { return; }
828+
if (!self.opts.disableOneColumnMode && (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) <= self.opts.minWidth) {
829+
if (self.oneColumnAutoMode) { return; }
830830

831831
self.container.addClass(self.opts.oneColumnModeClass); // TODO: legacy do people still depend on style being there ?
832+
self.oneColumnAutoMode = true;
832833
self.setColumn(1);
833834
} else {
834-
if (!self._prevColumn || self.opts.staticGrid) { return; }
835+
if (!self.oneColumnAutoMode) { return; }
835836

836837
self.container.removeClass(self.opts.oneColumnModeClass);
838+
self.oneColumnAutoMode = false;
837839
self.setColumn(self._prevColumn);
838840
}
839841
};

0 commit comments

Comments
 (0)