whenImagesLoaded

Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.when

Detect when some images are loaded. This function take advantage of the SPromise class and trigger an event called “img.loaded” that will be triggered on each loaded images and another called “loaded” once all the images are loaded. See in the example bellow.

Params

  1. $imgs*-Array<HTMLImageElement>

    An array (or nodeList) of HTMLImageElement to detect the load

Return

  1. -Promise

    A promise resolved when all images are loaded properly

Example

import { whenImagesLoaded } from '@blackbyte/sugar/dom'
whenImagesLoaded([
	$img1, $img2, $img3
]).then(imgs => {
  // do something here
})

Todo

  • testsnormal