rnmp / salvattore

A jQuery Masonry alternative with CSS-driven configuration.
https://salvattore.js.org/
MIT License
2.17k stars 243 forks source link

Adding columnsChange dispatch after init #200

Open efc opened 7 years ago

efc commented 7 years ago

I would like to synchronize the height of my parent container (the div with the data-columns attribute attached) so that it matches the hight of the tallest masonry-column. I could do this with JavaScript if I were alerted each time Salvattore finished adding or removing items from its columns. Is there any kind of "salvattore-done" message I can listen for (a jQuery(document.body).on('salvattore-done', ...) kind of thing) so that my script to take over with the cleanup?

If not, I would suggest an enhancement to send a message of this sort.

In this case, do you have any suggestions how I could monitor Salvattore to know when to step in, or alternatively, any other suggestions for keeping the parent container height in sync?

efc commented 7 years ago

On closer inspection, I believe my request may boil down to dispatching a columnsChange at the end of the init. This is already done at the end of a recreateColumns, but my argument would be that creating the columns in the first place is also a change to the columns.

Once this dispatch was in place, I could catch it to update my container height. Any later appending or removing from the container is something I am controlling, so I can manage the container height fix without a dispatch on those. The media-related resizing already dispatches the event.