Last active
February 7, 2016 18:24
-
-
Save christianwish/4899cf52d13bddd1ab6e to your computer and use it in GitHub Desktop.
simple-masonry.js examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
simpleM.columnsLength() | |
// returns number of available colums |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// iterate trough all items | |
simpleM.each(function (item, index) { | |
// do stuff | |
}); | |
// or to all items of a single column | |
simpleM.each(function (item, index) { | |
// do stuff | |
}, columnIndex); | |
// tip: use native Array-iterator | |
simpleM.get().forEach(function (item, index) { | |
// do stuff | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get all items in an array | |
simpleM.get(); | |
// get all items in an array of the column with this index | |
simpleM.get(index); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var simpleM = new SimpleMasonry(); | |
simpleM.init(); | |
//In case you want to use your own css classes: | |
var simpleM = new SimpleMasonry({ | |
masonryBox: '.my-box-class', | |
masonryColumn: '.my-column-class' | |
}); | |
simpleM.init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
simpleM.on('append', function (item) { | |
// do something with appended item | |
}); | |
simpleM.on('prepend', function (item) { | |
// do something with prepended item | |
}); | |
simpleM.on('order', function (items) { | |
// do something with all items | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var simpleM = new SimpleMasonry(); | |
simpleM.init(); | |
simpleM.prepend(document.getElementById('item-prepend')); | |
simpleM.append(document.getElementById('item-append')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- wrap columns --> | |
<section class="masonry-box container"> | |
<!-- columns 1 --> | |
<div class="masonry-column col-lg-3 col-md-4 col-sm-6 col-xs-12"> | |
<div class="item"> | |
<h3>item 1</h3> | |
</div> | |
<!-- item 2 is allready in the second masonry-column --> | |
<!-- item 3 is allready in the third masonry-column --> | |
<div class="item"> | |
<h3>item 4</h3> | |
</div> | |
<div class="item"> | |
<h3>item 5</h3> | |
</div> | |
<div class="item"> | |
<h3>item 6</h3> | |
</div> | |
<div class="item"> | |
<h3>item 7</h3> | |
</div> | |
<div class="item"> | |
<h3>item 8</h3> | |
</div> | |
</div> | |
<!-- columns 2 --> | |
<div class="masonry-column col-lg-3 col-md-4 col-sm-6"> | |
<div class="item"> | |
<h3>item 2</h3> | |
</div> | |
</div> | |
<!-- columns 3 --> | |
<div class="masonry-column col-lg-3 col-md-4"> | |
<div class="item"> | |
<h3>item 3</h3> | |
</div> | |
</div> | |
<!-- columns 4 --> | |
<div class="masonry-column col-lg-3"></div> | |
</section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment