Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.
/ imgz Public archive

Tiny image sources loader. 🖼️

License

Notifications You must be signed in to change notification settings

joseluisq/imgz

Repository files navigation

Imgz npm npm Build Status JavaScript Style Guide

Tiny image sources loader. 🖼️

Imgz just loads string image URLs by index emitting a callback with image, index and event parameters per load.

Install

Yarn

yarn add imgz

NPM

npm install imgz --save

The UMD build is also available on unpkg.

<link rel="stylesheet" href="https://unpkg.com/imgz/dist/imgz.min.js">

You can use the library via window.imgz

Usage

import { Loader } from 'imgz'

const images = [
  'https://i.imgur.com/G5MR088.png',   // ok!
  'http://server/not-found-image.png', // error!
  'https://i.imgur.com/G5MR088.png'    // ok!
]

Loader(images, (image: HTMLImageElement | null, index: number, event: LoadEvent | ErrorEvent) => { })

API

function Loader (
  // Sources
  source: string | string[],

  // Source loaded
  (image: HTMLImageElement | null, index: number, event: LoadEvent | ErrorEvent) => void,

  // Sources completed (optional)
  (length: number) => void
)

See index.d.ts for more details.

Contributions

Pull requests or issues are very appreciated.

License

MIT license

© 2018 José Luis Quintana