Packery
Bin-packing layout library
See packery.metafizzy.co for complete docs and demos
Install
Download
CDN
Link directly to Packery files on unpkg.
<script src="https://unpkg.com/packery@3/dist/packery.pkgd.js"></script>
<script src="https://unpkg.com/packery@3/dist/packery.pkgd.min.js"></script>
Package managers
npm: npm install packery --save
Bower: bower install packery --save
License
Packery v3 is licensed under the MIT license.
Initialize
With jQuery
$('.grid').packery({
itemSelector: '.grid-item'
});
With vanilla JavaScript
var grid = document.querySelector('.grid');
var pckry = new Packery( grid, {
itemSelector: '.grid-item'
});
var pckry = new Packery('.grid', {
});
With HTML
Add a data-packery
attribute to your element. Options can be set in JSON in the value.
<div class="grid" data-packery='{ "itemSelector": ".grid-item" }'>
<div class="grid-item"></div>
<div class="grid-item"></div>
...
</div>
By Metafizzy