gilbitron / flexmasonry

A lightweight masonry (cascading grid layout) library powered by flexbox.
https://flexmasonry.now.sh
MIT License
436 stars 25 forks source link

refresh method #1

Open V0IDNIL opened 5 years ago

V0IDNIL commented 5 years ago

Hi, How would I use the refresh method? I've tried to refresh the grid with the click of a button, but that doesn't work.

const fm = FlexMasonry.init('.grid', {
    breakpointCols: {
        'min-width: 960px': 5,
        'min-width: 768px': 4,
        'min-width: 576px': 3,
        'min-width: 450px': 2,
    }
});

document.getElementById('refresh').addEventListener('click', function() {
    fm.refresh();
});

Could you please tell me what I'm doing wrong? Sorry, I'm having a very limited understanding of Javascript. My apologies for that.

Thank you Klaas

gilbitron commented 5 years ago

So you can either use refreshAll:

FlexMasonry.refreshAll();

Or you can refresh an individual grid:

var grid = document.getElementById('my-grid');
FlexMasonry.refresh(grid);