Tuesday, October 21, 2014

Re: How to figure out HTMLPanel rendering is complete

Thanks for your suggestions. Yes, we are doing incremental loading. I will try out your suggestions.

On Saturday, 18 October 2014 03:23:29 UTC+5:30, Steve C wrote:

I'm guessing that you're doing incremental loading - that as soon as the user reaches the bottom of the current content, you get more?

You could remove the scroll handler when you start to load the HTML, and then restore it when the HTML has been received. Or have the loading mechanism set a flag and unset it when done, and the scroll handler checks that flag before doing anything (maybe better to use an integer count, increment when starting load, decrement when complete, and scrolll handler only works when it's zero).

But, if there are images in the received content, they will be loading asynchronously after that, which will affect the size of the content.  The best* way I can think of to handle that is to scan the received HTML looking for img tags, and then add a native JS load/error handler to each one, and keep a running count.  The load handler would decrement the count, and, when it reaches 0, all images will be loaded.  You might still need a deferred command, since just because the image has loaded doesn't mean that the DOM has reflowed.

*Maybe the second best way.  If you used an iframe as your loader instead of GWT's Ajax mechanism, you could set a readystatechange handler.  readyState 4 is supposed to mean that everything has been received, including images.  But, I don't know how well supported that is across browsers.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment