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.
52 lines
1.4 KiB
52 lines
1.4 KiB
var Isotope = window.Isotope = require('../../js/isotope'); |
|
var eventie = require('eventie'); |
|
var matchesSelector = require('desandro-matches-selector'); |
|
|
|
// require('isotope-fit-columns'); |
|
// require('isotope-cells-by-column'); |
|
// require('isotope-horizontal'); |
|
// require('isotope-masonry-horizontal'); |
|
|
|
function getText( elem ) { |
|
return elem.textContent || elem.innerText; |
|
} |
|
|
|
var iso = window.iso = new Isotope( '#container', { |
|
layoutMode: 'fitRows', |
|
transitionDuration: '0.8s', |
|
cellsByRow: { |
|
columnWidth: 130, |
|
rowHeight: 140 |
|
}, |
|
getSortData: { |
|
number: '.number parseInt', |
|
symbol: '.symbol', |
|
name: '.name', |
|
category: '[data-category]', |
|
weight: function( itemElem ) { |
|
// remove parenthesis |
|
return parseFloat( getText( itemElem.querySelector('.weight') ).replace( /[\(\)]/g, '') ); |
|
} |
|
} |
|
}); |
|
|
|
var options = document.querySelector('#options'); |
|
|
|
eventie.bind( options, 'click', function( event ) { |
|
if ( !matchesSelector( event.target, 'button' ) ) { |
|
return; |
|
} |
|
|
|
var key = event.target.parentNode.getAttribute('data-isotope-key'); |
|
var value = event.target.getAttribute('data-isotope-value'); |
|
|
|
if ( key === 'filter' && value === 'number-greater-than-50' ) { |
|
value = function( elem ) { |
|
var numberText = getText( elem.querySelector('.number') ); |
|
return parseInt( numberText, 10 ) > 40; |
|
}; |
|
} |
|
console.log( key, value ); |
|
iso.options[ key ] = value; |
|
iso.arrange(); |
|
});
|
|
|