mirror of https://github.com/metafizzy/isotope
Filter & sort magical layouts
http://isotope.metafizzy.co
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.7 KiB
105 lines
2.7 KiB
11 years ago
|
<!doctype html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
|
||
|
<title>insert</title>
|
||
|
|
||
10 years ago
|
<link rel="stylesheet" href="sandbox.css" />
|
||
11 years ago
|
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<h1>insert</h1>
|
||
|
|
||
11 years ago
|
<p><button id="insert">Insert</button> <button id="append">Append</button></p>
|
||
11 years ago
|
|
||
|
<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/eventEmitter/EventEmitter.js"></script>
|
||
|
<script src="../bower_components/eventie/eventie.js"></script>
|
||
|
<script src="../bower_components/doc-ready/doc-ready.js"></script>
|
||
|
<script src="../bower_components/get-style-property/get-style-property.js"></script>
|
||
|
<script src="../bower_components/get-size/get-size.js"></script>
|
||
|
<script src="../bower_components/jquery-bridget/jquery.bridget.js"></script>
|
||
|
<script src="../bower_components/matches-selector/matches-selector.js"></script>
|
||
|
<script src="../bower_components/outlayer/item.js"></script>
|
||
|
<script src="../bower_components/outlayer/outlayer.js"></script>
|
||
11 years ago
|
<script src="../bower_components/masonry/masonry.js"></script>
|
||
11 years ago
|
|
||
|
<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>
|
||
11 years ago
|
<script src="../js/layout-modes/masonry.js"></script>
|
||
11 years ago
|
|
||
|
<script>
|
||
|
|
||
|
docReady( function() {
|
||
|
|
||
|
var container = document.querySelector('#container');
|
||
|
var iso = new Isotope( container, {
|
||
11 years ago
|
layoutMode: 'masonry',
|
||
11 years ago
|
transitionDuration: '0.8s',
|
||
11 years ago
|
getSortData: {
|
||
|
b: 'b parseInt'
|
||
|
},
|
||
|
sortBy: 'b',
|
||
|
// filter b greater than 40
|
||
|
filter: function( elem ) {
|
||
|
return parseInt( getText( elem.querySelector('b') ), 10 ) > 40
|
||
|
}
|
||
|
});
|
||
|
|
||
|
eventie.bind( document.querySelector('#insert'), 'click', function() {
|
||
|
// append 3 new items
|
||
11 years ago
|
iso.insert( [ getItem(), getItem(), getItem() ] );
|
||
11 years ago
|
});
|
||
|
|
||
|
eventie.bind( document.querySelector('#append'), 'click', function() {
|
||
|
// append 3 new items
|
||
11 years ago
|
iso.appended( [ appendItem(), appendItem(), appendItem() ] );
|
||
11 years ago
|
});
|
||
|
|
||
11 years ago
|
function getItem() {
|
||
11 years ago
|
var item = document.createElement('div');
|
||
|
item.className = 'item';
|
||
|
var num = Math.floor( Math.random() * 100 );
|
||
|
item.innerHTML = '<b>' + num + '</b>';
|
||
11 years ago
|
return item;
|
||
|
}
|
||
|
|
||
|
function appendItem() {
|
||
|
var item = getItem();
|
||
11 years ago
|
container.appendChild( item );
|
||
|
return item;
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
var docElem = document.documentElement;
|
||
|
|
||
|
var getText = docElem.textContent ?
|
||
|
function( elem ) {
|
||
|
return elem.textContent;
|
||
|
} :
|
||
|
function( elem ) {
|
||
|
return elem.innerText;
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
</script>
|
||
|
|
||
|
</body>
|
||
|
</html>
|