Skip to content

Only one instance of Flexmasonry working #12

@benhaldenby

Description

@benhaldenby

I have two pages on a site where I want to create two separate, different instances of Flexmasonry. But only one the instances is working.

One page has a UL of images, the other a UL of divs with text content. I have the Flexmasonry code in two separate JS files which are built and minified with Gulp into a single main.js file, which is included on both pages. It seems that whichever of the instances comes last in the compiled JS file is the instance that works, and the previous one doesn't.

This is the un-minified fragment from the built main.js file:

document.addEventListener('DOMContentLoaded', function () {
  
  FlexMasonry.init('.js-image-gallery', {
    responsive: true,
    breakpointCols: {
        'min-width: 980px': 4,
        'min-width: 768px': 2
    },
  });
  
})

document.addEventListener('DOMContentLoaded', function () {
  
  FlexMasonry.init('.js-information-grid', {
    responsive: true,
    breakpointCols: {
      'min-width: 980px': 3,
      'min-width: 768px': 2
    },
  });
    
})

Here the .js-information-grid works, but the gallery does not. If switched in order, then the other works.

Is this a known issue with Flexmasonry?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions