neft
Version:
Universal Platform
28 lines (23 loc) • 849 B
text/coffeescript
module.exports = (impl) ->
loadResources: (resources) ->
self = @
length = 1
loaded = 0
onLoaded = ->
if is Image.Ready or is Image.Error
()
self.progress = ++loaded / length
return
for resource in resources
for _, resolutions of resource.paths
for resolution, path of resolutions
length++
img = impl.utils.createQmlObject 'Image { asynchronous: true }'
img.source = 'qrc:' + path
if img.status is Image.Loading
img.statusChanged.connect img, onLoaded
else
onLoaded.call img
self.progress = ++loaded / length
return