react-snuggle
react-snuggle copied to clipboard
Sugestion about hook
Did you think that is relevant a "onLayoutComplete" hook?
Hey @gabrielbs, great question
Actually, there is a way to catch onLayoutUpdated (but it still needs implementation), but it's not possible to know when the layout is completed (all updates are finished). Also, I'm thinking what is more interesting, to catch the onLayoutUpdated or onLayoutCompleted, because if you're using a third library into the react-snuggle, you should know every time the layout is updated and not only at the end of all updates (we don't know how many updates will exist in the layout).
When the layout will update?
componentDidMount: when the component is mounted;- Reposition items once after mounted: the layout needs a trigger to calculate its correct position;
onLoadImages: after each image is loaded, the layout will be updated. So the layout will update the same amount of time the number of images.
What can we do?
I think we can put a callback at the end setValues function. (https://github.com/Significa/react-snuggle/blob/master/src/index.js#L43). And I think we can improve the name of this function (updateLayout is better, or if you have another suggestion).
So, @gabrielbs if you want, feel free to open a PR with this changes and let me know your thought about this 🍺