haltu / muuri

Infinite responsive, sortable, filterable and draggable layouts
https://muuri.dev
MIT License
10.8k stars 644 forks source link

Refreshing item position after filtering #425

Closed danielriosb closed 4 years ago

danielriosb commented 4 years ago

Hello, really nice work with this library. Hope someone can guide me with this. So what I'm trying to do is set default filters for the grid. Basically after calling grid.init() and call grid.filter to filter the items based on a dropdown value. The figure is, I have to items and I filter one. The issue is that the filtered item doesn't show anymore but the second item doesn't move to the position of the first item. I try calling refreshItems, refreshSortData, synchronize, layout but nothing moves the item to the first position. Thanks

danielriosb commented 4 years ago

I wrote this and its is working now.

let defaultLayout = () => {
            grid._settings.layout = {
                horizontal: true,
                alignRight: false,
                alignBottom: false,
                fillGaps: true
            };
            grid.layout();
        }

        defaultLayout();