I would like to be able to know when all views have been rendered in a layout. The reason I want to do this is because I need to be able to reference positions of rendered views in the layout, so that I may animate views relative to other views that had already been rendered.
I have read this: Surface render events in famo.us
One way I can think of is to count views that have been rendered and after all had been rendered (based on a known count), I can then assume all have been rendered. Obviously this would not work if there's an unknown number of views to render.
So another way to achieve this would be to have the layout fire a custom event when all of its managed surfaces have completed rendering. It seems like a good place to do this would be in a function shim in the given layout. For example, in SequentialLayout it would be SequentialLayout.prototype.commit
. But, I am not 100% certain on whether that's the right approach, because it looks like the Engine
or Entity
manages the rendering. So, what that smells like to me is that this approach wouldn't actually fire the event I want fired at the right time.
Are there any best practices for this?