angular-ui-router-styles icon indicating copy to clipboard operation
angular-ui-router-styles copied to clipboard

State loading synchronization

Open slavafomin opened this issue 9 years ago • 4 comments
trafficstars

Hello @manuelmazzuola!

It's me back again )

I've encountered another issue with the module during it's use in one of our projects.

The problem is that the module loads stylesheets AFTER the state transition is complete and $viewContentLoaded event is triggered, i.e. when DOM of the view is compiled and rendered. Because of that some plugins are not working correctly, cause they need to know element dimensions during the initialization (and dimensions are not correct because stylesheets are not yet loaded).

I think that from conceptual standpoint view depends on CSS, so the CSS should be loaded prior to view being rendered and compiled.

Does it make sense to you? If so, we could think further of how we could improve this situation.

slavafomin avatar Mar 02 '16 10:03 slavafomin

Hello @manuelmazzuola and @slavafomin

Same issue to me. There is always a "ugly time" before the css was loaded. I'm wondering is there any way to load the css file before the view is rendered.

ming-body7 avatar Apr 15 '16 07:04 ming-body7

There is a way to check if the css files are effectively loaded and fire an event, but, you have to wait for that event before rendering the template.

manuelmazzuola avatar Apr 15 '16 08:04 manuelmazzuola

Hello @ming-body7 I've developed a module for Angular that tries to solve the problem of loading CSS dynamically, please have a look. It's kinda experimental, but we are using it in our production projects. It loads CSS during the resolve phase of the state transition and fires events when loading is started and finished.

slavafomin avatar Apr 16 '16 11:04 slavafomin

@slavafomin Thanks for your remind! I will try it.

ming-body7 avatar Apr 16 '16 22:04 ming-body7