Resize hidden DOM element BEFORE showing them in jQuery
I have been having this problem in a lot of websites we build. Basicaly, the global scope is this:
- The website shall adapted itself to all different window sizes
- Users navigate in it with the keyboard OR the mouse
- All the different sections of pages are already there (hidden) or loaded via Ajax (no url change)
- Some elements (like images) need to keep the original aspect ratio
- Some element (like paragraphs) have a fixed width, but no known height (auto)
- When the website load, only the first section is visible.
Right now, I tried this:
- Saving all the element's original width and height on init: This fails because images are not loaded...
- Saving all the element's original width and height on load: This adds a delay that is not wanted
- Do a mix of the two first solution, on init for text, on load for images: This works as wanted, but only if the element is visible and that all his parents are too.
- On resize, show all, resi开发者_开发百科ze, hides those that need to be hidden... This lagged all browsers.
- On resize stop (50 msec after the last resize event): This prevent the animated flow on all individual resize events.
So, this brings us to the question title...
Anybody has something on this kind of situation ?
精彩评论