haltu / muuri

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

grid.show() doesn't toggle items on, but grid.hide() toggles off. #563

Closed ogrotten closed 7 months ago

ogrotten commented 7 months ago

The syntaxes for the methods appears to be the exact same, but firing hide/show the exact same way doesn't work for show.

The muuri object is set up as mu and so far it works in every other respect.

I've setup images as an array of HTMLElements and added custom attribs/data to it for generalities.

changed comes from a higher component, and this function fires whenever it has been set like shown.

changed = { id: myObject.id, added: false }

const setItemVis = (changed) => {
    const el = images.filter(i => i.getAttribute('data-muuri-id') === changed.id)
    const item = mu.getItem(el[0])

    if (changed.added) mu.show([item])
    else mu.hide([item])

    changed = null

    const check = mu?.getItems().filter(i => i.isVisible())
    console.log(`\nchk.length, chk`, chk.length, chk)
}

onFinish fires, but check as defined above does not change. IOW, if there's 5 imgs and I add one, it still says 5.

mu.on("layoutEnd") does not fire. even when set to mu.show([item], { layout: true })

Of course, reloading the page,

Suggestions?

ogrotten commented 7 months ago

NEVERMIND.

Took a while, but I found that the show/hide toggle data I was passing in to muuri was bad.