jQuery Masonry / Isotope and fluid images: Momenta

2019-07-21 20:57发布

I've noticed that when using jQuery Isotope or Masonry with a fluid / responsive website, the elements overlap momentarily whilst the browser window is being resized. Please see the images below, which are screenshots from this demo. You can also see this happening on the Isotope website.

Is there anything that can be done to avoid this overlapping?

Before resizing the browser window: a nicely spaced grid of images

During resizing: overlapping!

After resizing: back to the nice grid.

3条回答
看我几分像从前
2楼-- · 2019-07-21 21:50

For Isotope version 3 use:

$(window).resize(function(){ $('.grid').isotope('layout'); });

to avoid overlapping grid items.

查看更多
Anthone
3楼-- · 2019-07-21 21:50

Thanks for you above comments...i got the answer for my problem from here but how i just want to explain to u-> i am using ajax page load using isotope so my code is-

var $container = $('your main container in which your all item will get listed');
 $container.imagesLoaded(function () {
     $container.isotope({
         itemSelector: 'figure',
         filter: '*',
         resizable: false,
         animationEngine: 'jquery'
     });
 });

after that when i call my ajax use to call this function

$("#filter-container").isotope('reLayout');

On first page load there will be some data on page so isotope will adjust all that and after appending ajax loaded data isotope will re arrange all of them.

查看更多
【Aperson】
4楼-- · 2019-07-21 21:56

Thanks to Osvaldas Valutis for answering this question over on his blog post (http://osvaldas.info/responsive-jquery-masonry-or-pinterest-style-layout).

--

For Masonry:

$(window).resize(function(){ $('#list').masonry('reload'); });

And the following works for me, using Isotope:

$(window).resize(function(){ $('#list').isotope('reLayout'); });

--

Thanks again, Osvaldas.

查看更多
登录 后发表回答