bigbite / macy.js

http://macyjs.com/
MIT License
1.28k stars 156 forks source link

Add class to container when Macy is initialized? #93

Open nickpish opened 2 years ago

nickpish commented 2 years ago

First off, thank you for a fantastic light-weight masonry plugin! I'm wondering how I might add a macy-init class to the container element when Macy has initialized? I've tried the following using an event key, but it doesn't seem to be working:

let macy = Macy({container: '.container'});
macy.on(macy.constants.EVENT_INITIALIZED, function() {
   var container = document.querySelector('.container');
   container.classList.add('macy-init');
});

Thanks for any insight here.

lzj666888 commented 2 years ago

You can edit the source code. In setup function, add the async function to wrap "emit EVENT_INITIALIZED". But this may not be logical. I think the best way to resolve this question is to extract an initalization lifecycle function.