|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width" />
|
|
|
|
|
|
|
|
<title>insert</title>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="sandbox.css" />
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h1>insert</h1>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
<button id="prepend">Prepend</button>
|
|
|
|
<button id="insert">Insert</button>
|
|
|
|
<button id="append">Append</button>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<div id="container">
|
|
|
|
<div class="item"><b>49</b></div>
|
|
|
|
<div class="item"><b>35</b></div>
|
|
|
|
<div class="item"><b>60</b></div>
|
|
|
|
<div class="item"><b>29</b></div>
|
|
|
|
<div class="item"><b>78</b></div>
|
|
|
|
<div class="item"><b>92</b></div>
|
|
|
|
<div class="item"><b>10</b></div>
|
|
|
|
<div class="item"><b>55</b></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script src="../bower_components/ev-emitter/ev-emitter.js"></script>
|
|
|
|
<script src="../bower_components/get-size/get-size.js"></script>
|
|
|
|
<script src="../bower_components/desandro-matches-selector/matches-selector.js"></script>
|
|
|
|
<script src="../bower_components/fizzy-ui-utils/utils.js"></script>
|
|
|
|
<script src="../bower_components/outlayer/item.js"></script>
|
|
|
|
<script src="../bower_components/outlayer/outlayer.js"></script>
|
|
|
|
<script src="../bower_components/masonry/masonry.js"></script>
|
|
|
|
|
|
|
|
<script src="../js/item.js"></script>
|
|
|
|
<script src="../js/layout-mode.js"></script>
|
|
|
|
<script src="../js/isotope.js"></script>
|
|
|
|
<script src="../js/layout-modes/fit-rows.js"></script>
|
|
|
|
<script src="../js/layout-modes/masonry.js"></script>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
var container = document.querySelector('#container');
|
|
|
|
var iso = new Isotope( container, {
|
|
|
|
layoutMode: 'masonry',
|
|
|
|
stagger: 50,
|
|
|
|
transitionDuration: '0.8s',
|
|
|
|
getSortData: {
|
|
|
|
b: 'b parseInt'
|
|
|
|
},
|
|
|
|
sortBy: 'b',
|
|
|
|
// filter b greater than 40
|
|
|
|
// filter: function( elem ) {
|
|
|
|
// return parseInt( elem.querySelector('b').textContent, 10 ) > 40
|
|
|
|
// }
|
|
|
|
});
|
|
|
|
|
|
|
|
document.querySelector('#prepend').addEventListener( 'click', function() {
|
|
|
|
// prepend 3 new items
|
|
|
|
iso.prepended( [ prependItem(), prependItem(), prependItem() ] );
|
|
|
|
});
|
|
|
|
|
|
|
|
document.querySelector('#insert').addEventListener( 'click', function() {
|
|
|
|
// insert 3 new items
|
|
|
|
iso.insert( [ getItem(), getItem(), getItem() ] );
|
|
|
|
});
|
|
|
|
|
|
|
|
document.querySelector('#append').addEventListener( 'click', function() {
|
|
|
|
// append 3 new items
|
|
|
|
iso.appended( [ appendItem(), appendItem(), appendItem() ] );
|
|
|
|
});
|
|
|
|
|
|
|
|
function getItem() {
|
|
|
|
var item = document.createElement('div');
|
|
|
|
item.className = 'item';
|
|
|
|
var num = Math.floor( Math.random() * 100 );
|
|
|
|
item.innerHTML = '<b>' + num + '</b>';
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
function prependItem() {
|
|
|
|
var item = getItem();
|
|
|
|
container.insertBefore( item, container.firstChild );
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
function appendItem() {
|
|
|
|
var item = getItem();
|
|
|
|
container.appendChild( item );
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
iso.on( 'layoutComplete', function() {
|
|
|
|
console.log('layout complete');
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|