Skip to content

Items get correctly displayed on 3 columns when using one filter, but get stacked on a single column if using a different filter #1663

Open
@vankishdelfuturo

Description

@vankishdelfuturo

Go to the portfolio section of www.vankish.com

When using the filters ALL and GRAPHICS, it works properly.
When using the filter VIDEO, the items will only use one column.

Makes no sense. I have tried everything. I have read all the docs and lots of similar issues posted here, but still nothing.

Here's the relevant .js

  // Event listener for handling portfolio filtering and initializing Isotope and Masonry
  window.addEventListener('load', () => {
    let portfolioContainer = select('.portfolio-container');
    if (portfolioContainer) {
      let portfolioIsotope = new Isotope(portfolioContainer, {
        itemSelector: '.portfolio-item',
        layoutMode: 'fitRows'
      });

      let portfolioFilters = select('#portfolio-filters li', true);

      var masonry = new Masonry(portfolioContainer, {
        itemSelector: '.portfolio-item',
        columnWidth: '.portfolio-item',
        percentPosition: true
      });

      // Event listener for portfolio filter clicks
      on('click', '#portfolio-filters li', function(e) {
        e.preventDefault();
        portfolioFilters.forEach(function(el) {
          el.classList.remove('filter-active');
        });
        this.classList.add('filter-active');

        portfolioIsotope.arrange({
          filter: this.getAttribute('data-filter')
        });

        // After updating the filter, reload and layout Masonry
        setTimeout(function() {
          masonry.reloadItems();
          masonry.layout();
        }, 500);
      }, true);
    }
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions