queue ImageLoader downloads
This commit is contained in:
parent
2e5024483c
commit
5c28ed45f2
@ -52,12 +52,27 @@ ImageLoader =
|
|||||||
el.style.maxWidth = style.maxWidth
|
el.style.maxWidth = style.maxWidth
|
||||||
el.loop = true
|
el.loop = true
|
||||||
el.className = thumb.className
|
el.className = thumb.className
|
||||||
event = if isVideo then 'loadeddata' else 'load'
|
|
||||||
cb = =>
|
cb = =>
|
||||||
$.off el, event, cb
|
$.off el, 'load loadeddata', cb
|
||||||
ImageLoader.replace @, el
|
ImageLoader.replace @, el
|
||||||
$.on el, event, cb
|
$.on el, 'load loadeddata', cb
|
||||||
el.src = URL
|
ImageLoader.queue.push [el, URL]
|
||||||
|
ImageLoader.next() unless ImageLoader.busy
|
||||||
|
|
||||||
|
busy: false
|
||||||
|
queue: []
|
||||||
|
|
||||||
|
loadend: ->
|
||||||
|
$.off @, 'load loadeddata error', ImageLoader.loadend
|
||||||
|
ImageLoader.busy = false
|
||||||
|
ImageLoader.next()
|
||||||
|
|
||||||
|
next: ->
|
||||||
|
return if ImageLoader.busy
|
||||||
|
if [el, URL] = ImageLoader.queue.shift()
|
||||||
|
$.on el, 'load loadeddata error', ImageLoader.loadend
|
||||||
|
el.src = URL
|
||||||
|
ImageLoader.busy = true
|
||||||
|
|
||||||
replace: (post, el) ->
|
replace: (post, el) ->
|
||||||
{file} = post
|
{file} = post
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user