gridstack.js issue base
Use this as a base for examples for gridstack.js issues.
HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gridstack@10.0.1/dist/gridstack.min.css">
<script src="https://cdn.jsdelivr.net/npm/gridstack@10.0.1/dist/gridstack-all.js"></script>
<h1>gridstack.js base demo for issues</h1>
<p>Fork and modify me to demonstrate your issue when creating an issue for gridstack.js</p>
<button onClick="addNewWidget()">Add Widget</button>
<div class="grid-stack"></div>
CSS
.grid-stack {
background: lightgoldenrodyellow;
--resize-border: 3px solid black;
}
.grid-stack-item-content {
color: #2c3e50;
text-align: center;
background-color: #18bc9c;
}
.ui-resizable-handle.ui-resizable-w:hover {
border-left: var(--resize-border);
}
.ui-resizable-handle.ui-resizable-e:hover {
border-right: var(--resize-border);
}
.ui-resizable-handle.ui-resizable-n:hover {
border-top: var(--resize-border);
}
.ui-resizable-handle.ui-resizable-s:hover {
border-bottom: var(--resize-border);
}
/*Missing CSS here*/
.ui-resizable-handle.ui-resizable-e:hover, .ui-resizable-handle.ui-resizable-w:hover {
top: 0.5rem;
bottom: 0.5rem;
}
.ui-resizable-handle.ui-resizable-s:hover, .ui-resizable-handle.ui-resizable-n:hover {
left: 0.5rem;
right: 0.5rem;
}
.ui-resizable-handle.ui-resizable-n {
top: 0.5rem;
}
.ui-resizable-handle.ui-resizable-s {
bottom: 0.5rem;
}
JavaScript
var count = 0;
var items = [
{x: 0, y: 0, w: 2, h: 2},
{x: 2, y: 0, w: 2},
];
items.forEach(w => w.content = String(count++));
var options = { // put in gridstack options here
resizable: { handles: 'all'},
margin: '0.5rem'
};
var grid = GridStack.init(options).load(items);
addNewWidget = function () {
var node = {
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()),
content: String(count++)
};
grid.addWidget(node);
return false;
};