gridie.js helps you building dynamic draggable/resizable layouts quickly. It's a standalone library inspired in gridstack.js and packery. It features multiple columns, non-fixed items height, mobile support and a quite small size (~6kb minified).
Just include gridie.js
and gridie.css
between your stuff and you're ready to go.
Gridie is also available as an npm module you can use along with browserify. Just $ npm install gridie
it.
All you need is a container element with a series of similar item elements, like:
<div id="container">
<div class="cell" data-x="0">Item 1</div>
<div class="cell" data-x="1">Item 2</div>
<div class="cell" data-x="2">Item 3</div>
</div>
The minimal data each item needs is a data-x
attribute, representing a column.
data-x
item's horizontal position. This represents a column number. Requireddata-y
item's vertical position in pixels. If not set, elements are stacked in orderdata-width
item's width in columns (ie. not pixels). Defaults to1
Then you can initialize the layout passing the container element, and an optional settings object:
var g = new Gridie(document.getElementById('container'), {
columns: 6,
selector: '.cell',
resize: true,
drag: true
});
columns
amount of columns, defaults to 6selector
items selector, defaults to'.cell'
resize
whether items could be resized or not. Could be false, true or a settings object. Defaults totrue
handler
selector for a resize handler element
drag
whether items could be dragged or not. Could be false, true or a settings object. Defaults totrue
handler
selector for a drag handler element
init
whether the layout should be rendered immediately or not. Defaults totrue
Released under the MIT License
Copyright (c) 2016 Nicolás Arias