I posted about this yesterday but there seemed to be some confusion. So am posting it again, and will try to be clearer this time around.
I am a big fan of this wordpress theme: http://prothemeus.com/demo/litho/ for the following reasons:
- it positions and scales the content tiles to always fill the browser window 100%
- when resizing the browser window it re-positions and re-scales these tiles so that it still fills the browser window 100%
- when resizing the browser window, the motion of the tiles is fluid. no gaps form between tiles, it has a very nice action to it all. Which I love.
- The tiles never get smaller than a certain amount, say 240px wide. Once they go smaller than 240px, the grid reshuffles the tiles so that there are less tiles in each row. (difficult to explain this, but play with the size of the browser window and hopefully you will see what I mean)
The things that doesn’t work for me about this theme:
- cannot display content tiles of varying sizes. this is key for me as I want to draw attention to certain posts. To be specific, featured post tiles are double the width and height of regular post tiles.
So as a result I have customised the theme by stripping out Litho theme’s javascript, renaming nodes and containers etc. And replacing it all with Packery libraries, which now position my content tiles:
$(document).ready( function() {
var $container = $('#grid');
// init
$container.packery({
itemSelector: '.grid-item',
columnWidth: 240,
});
});
However while this allows for me to have content of different sizes, it has now lost its fluid positioning.
Is there a way that Packery could replicate the same effect the Litho theme originally had?
I have looked around and the closest I have found is this:
http://codepen.io/desandro/pen/BEJhd
However it does not have the exact same motion, its a lot more clunky and not as aesthetically pleasing. There is overlap between the tiles, or gaps form between tiles.
I believe the difference is that the tiles are all rescaled first and then only repositioned once. Whereas the litho theme, would rescale and reposition the tiles at the same time, which looks much much nicer.
Secondly there is no minimum size for the tiles, when resizing the browser window they only shrink.
(I understand these actions may be slightly different in different browsers, but this is what I see on my Mac using Safari, Firefox and Chrome)
So my question is, is there a way that I can replicate Litho theme’s repositioning and rescaling action, but using Packery libraries? Does the Packery libraries even allow this?
Thank you
Rsx: based on your codepen and your comment “you need to resize the browser window initially to get it to start working”, your problem is simply that the javascript is “firing” before the images load. This is a common issue with Packery, and Metafizzy has their own convenient fix.
To implement the fix download and install Metafizzy’s imagesLoaded js: https://imagesloaded.desandro.com
You have to be careful about how you order the script calls in your html, depending on whether you want to call after each image is loaded or after all images are loaded. See the Packery site for more information: https://packery.metafizzy.co/layout.html#imagesloaded
As an example, here is my js call, which initializes Packery after all images load.
Regarding minimum size: I do not use this, but it should be be set-able in your css as
min-width
andmin-height
.Packery can work fluidly and in exactly the same manner in all major browsers. It does for me anyway.
Best of Luck!