-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event onReady #79
Event onReady #79
Conversation
Nice idea! I think we can just emit a The current setup, where |
Also you're right about the documentation; we should update that to make it clearer as well. Thanks for pointing this out! |
This reverts commit 0c94e34.
I updated the PR description and implemented your suggestion. With this there should be no breaking changes. |
/** | ||
* Adds a callback for when positioning is complete | ||
* @param callback - function to be called on positioning complete | ||
*/ | ||
onPositionComplete(callback: () => void): void; | ||
onPositionComplete(callback: () => void): number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
Awesome work. Thanks! |
Background
As I was working with the library, I encountered a function called onPositionComplete. According to its documentation, this function was meant to "add a listener used to execute a function once all items in the grid have been properly positioned." However, something about the name and the description felt off. It gave the impression that the listener would only be triggered a single time, likely on the first positioning of the items in the grid.
As I dug deeper into the code, it became clear that onPositionComplete actually behaved differently than what the name and documentation suggested. The listener wasn't just a one-time thing—it would trigger every time the positionItems() method was called or when the container was resized. This behavior was useful, but the existing naming and documentation didn't make that clear.
Changes
onReady
to run a listener only once, after the first positioning of items.