gridstack.js issue base
Use this as a base for examples for gridstack.js issues.
HTML
<script src="https://cdn.jsdelivr.net/npm/gridstack@5.1.0/dist/gridstack-h5.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gridstack@5.1.0/dist/gridstack.min.css">
<h1>Not swapping when dragging down.</h1>
<p>Unable to move 0 below 1 without creating a 3rd row but can move 1 above 0.</p>
<br />
<div class="grid-stack"></div>
CSS
.grid-stack {
background: lightgoldenrodyellow;
}
.grid-stack-item-content {
color: #2c3e50;
text-align: center;
background-color: #18bc9c;
}
JavaScript
var options = { // put in gridstack options here
disableOneColumnMode: true, // for jfiddle small window size
float: true
};
var grid = GridStack.init(options);
var count = 0;
var items = [
{x: 0, y: 0, w: 1, h: 1},
{x: 0, y: 1, w: 1},
{x: 3, y: 1, h: 2},
{x: 0, y: 2, w: 2},
];
addNewWidget = function (x,y, w, h) {
var node = items[count] || {
x: Math.round(12 * Math.random()),
y: Math.round(5 * Math.random()),
w: Math.round(1 + 3 * Math.random()),
h: Math.round(1 + 3 * Math.random())
};
node.content = String(count++);
grid.addWidget(node);
return false;
};
addNewWidget();
addNewWidget();