Reputation:
I need to run a script after window get resized and isotope finish operating. I thought callbacks would help but they're not fired in case of window resize.
As I need the updated container 's width value after resize, is there another way ?
Thanks for your help!
Upvotes: 1
Views: 845
Reputation: 163
this worked..
Similiar to a callback, onLayout is a function that will be triggered after every time an Isotope instance runs through its layout logic.
$('#container').isotope({
onLayout: function( $elems, instance ) {
// `this` refers to jQuery object of the container element
console.log( this.height() );
// callback provides jQuery object of laid-out item elements
$elems.css({ background: 'blue' });
// instance is the Isotope instance
console.log( instance.$filteredAtoms.length );
}
});
Upvotes: 1
Reputation: 4347
i was looking into that eather and couldnt find a solution. so i picked this ugly one:
$(window).smartresize(function () {
setTimeout(function () {
//your function
}, 810);
});
so on resize i set a timeout that calls 810ms after isotope relayout, which should take 800ms in jquery, or 0.8s in css3. like is said, its ugly, but for now i fits the purpose..
Upvotes: 0