I'm late to the party but congrats for this beautiful piece of code and for your detailed explanation on CodeBurst. It's not easy to "empty ourselves" and have a beginner's mind when writing so 👏.
I've noticed that you're not binding this to your public methods. This can have unexpected results when, for example passing a public method reference to a button listener (this becomes the button).
const mg = new MagicGrid({});
// error
someButton.addEventListener('click', mg.positionItems)
// works, but no reference, can't remove this listener after
someButton.addEventListener('click', () => mg.positionItems())
// works, but boilerplate
let mgPosItems = mg.positionItems();
someButton.addEventListener('click', mgPosItems)
Another use-case that popped into my mind was a destroy method.
I have given a try at implementing this and the above suggestions, so let me know if you interested in a PR.
I'm late to the party but congrats for this beautiful piece of code and for your detailed explanation on CodeBurst. It's not easy to "empty ourselves" and have a beginner's mind when writing so 👏.
I've noticed that you're not binding
this
to your public methods. This can have unexpected results when, for example passing a public method reference to a button listener (this
becomes the button)..destroy()
Another use-case that popped into my mind was a destroy method. I have given a try at implementing this and the above suggestions, so let me know if you interested in a PR.
Keep up the good work :) Cheers