metafizzy / isotope

:revolving_hearts: Filter & sort magical layouts
https://isotope.metafizzy.co
11.03k stars 1.42k forks source link

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 opened 6 months ago

vankishdelfuturo commented 6 months ago

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);
    }
  });
thesublimeobject commented 5 months ago

@vankishdelfuturo — i just took a look at the portfolio and it seems like the filters are no longer present: do you still need assistance with this?

vankishdelfuturo commented 5 months ago

Yes, i still do need the help! I removed the filters from my portfolio because i was unable to make them work properly. I'll share the code with you if you are down to check it out

What i did find out tho is this:

Conclusion:

I know they say something regarding this first item problem on the Isotope FAQs. I tried that solution and it still didn't work image

thesublimeobject commented 5 months ago

@vankishdelfuturo — yes please share your code, if possible. it will make it a bit easier to discuss (still might be difficult without a direct example of what's happening, but i can try).