P
P
Pavel Gonzales2015-10-26 16:37:48
JavaScript
Pavel Gonzales, 2015-10-26 16:37:48

How to restart masonry?

Hello.
I have a page with Masonry connected, and also a menu with a filter for blocks that fade out (fadeOut). When I click on the filter, the blocks disappear, but masonry doesn't position them properly, i.e. there are empty spaces in place of blocks.

I understand that you need to restart masonry after applying each filter. Or maybe there is an option to make masonry position them immediately after applying the filter without restarting.

// скрипт позиционирования блоков 
      $('#masonry-container').masonry({
        itemSelector: '.country-block',
        singleMode: false,
        isResizable: true,
        isAnimated: true,
        animationOptions: { 
        queue: false, 
        duration: 100
        }
        
        });
      // скрипт фильтра стран
      $(function() {
        var newSelection = "";
        $(".nav-menu").click(function(){
          $(".nav-menu").removeClass("selected");
          $(this).addClass("selected");
          newSelection = $(this).attr("rel");
          $(".country-block").not("."+newSelection).fadeOut(800);
          $("."+newSelection).fadeIn(800);
          $(".all-flavors").fadeTo(600, 1);
          });

        });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rikcon, 2015-10-26
@Rikcon

masonry.desandro.com/methods.html#reloaditems
here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question