thinkpixellab / PxLoader

PxLoader is a simple JavasScript library for creating preloaders and resource downloaders for HTML5 apps.
http://thinkpixellab.com/pxloader
1.11k stars 171 forks source link

progress listener outputs unpredictable sequence #10

Closed dadastudio closed 12 years ago

dadastudio commented 12 years ago

Images are not loaded in an order that I set up. progress listener outputs unpredictable sequence.

This situation is in a sample 2 http://thinkpixellab.com/pxloader/ Report Progress While Images Load.

I got this:

Image 1 Loaded Image 100 Loaded Image 6 Loaded Image 5 Loaded Image 4 Loaded Image 3 Loaded Image 7 Loaded ...

Is this a normal behaviour? When images are cached an order is as expected. I run on OSX 10.7.3 (Safari, Chrome, Firefox...)

joelfillmore commented 12 years ago

Yes, unfortunately we can only control the order that resources are requested. The resources may complete at different times for various reasons like transfer size or network delay. In most cases I think callers want to be notified as soon as a resource is ready. If you wanted sequential notifications it wouldn't be too hard to wrap the progress events and buffer notifications for events that arrive out of order.