masonry icon indicating copy to clipboard operation
masonry copied to clipboard

Re-initiliaze the masonry

Open Webinsane opened this issue 7 years ago • 1 comments

Hello. I am using latest version of masonry. I have issues on my search results page as I am opening and closing sidebar which pushes the images to smaller size. It works nicely only problem is that masonry leaves spaces between images. If I launch Firefox inspect tool it looks OK probably because inspect tool re-initializes the masonry. I tried to achieve this following some solutions on the web, but with no luck. The perfect solution would be to arrange masonry when opening and closing sidebar. This my code for masonry:

$(window).load(function(){
	// Rooms Masonry
	var container = $('.rooms.rooms-masonry > .rooms-inside');
	container.masonry({
	  itemSelector: '.room',
	  columnWidth: 1,
	});
	showSearchFields(window.SEARCH_TYPE);

});

Webinsane avatar Jan 21 '19 11:01 Webinsane

After the container size has changed, you should trigger .masonry() to re-layout the items.

desandro avatar Jan 22 '19 19:01 desandro