All Projects → lukeed → Onloaded

lukeed / Onloaded

Licence: mit
A tiny (350B) library to detect when images have loaded.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Onloaded

Imgix Swift
A Swift client library for generating URLs with imgix
Stars: ✭ 19 (-42.42%)
Mutual labels:  images
Cometa
Super fast, on-demand and on-the-fly, image processing.
Stars: ✭ 8 (-75.76%)
Mutual labels:  images
Tcodeedit
Lightweight and syntax hilighted UNICODE editor
Stars: ✭ 27 (-18.18%)
Mutual labels:  lightweight
Larastrator
All in one - admin panel with tailwindcss and vuejs.
Stars: ✭ 25 (-24.24%)
Mutual labels:  lightweight
Sv Images
Image manipulation library with an HTTP based API.
Stars: ✭ 7 (-78.79%)
Mutual labels:  images
Cicada
🚀 Fast lightweight HTTP service framework.
Stars: ✭ 851 (+2478.79%)
Mutual labels:  lightweight
React Native Cached Image
CachedImage component for react-native
Stars: ✭ 890 (+2596.97%)
Mutual labels:  images
Lightweight Human Pose Estimation.pytorch
Fast and accurate human pose estimation in PyTorch. Contains implementation of "Real-time 2D Multi-Person Pose Estimation on CPU: Lightweight OpenPose" paper.
Stars: ✭ 958 (+2803.03%)
Mutual labels:  lightweight
Librg
🚀 Making multi-player gamedev simpler since 2017
Stars: ✭ 813 (+2363.64%)
Mutual labels:  lightweight
Humblelogging
HumbleLogging is a lightweight C++ logging framework. It aims to be extendible, easy to understand and as fast as possible.
Stars: ✭ 15 (-54.55%)
Mutual labels:  lightweight
Python Compare Images
This repository is mainly about comparing two images. The technique used is SSIM. i.e. Structural Similarity Index Measure We use some of the inbuilt functions available in python's skimage library to measure the SSIM value. Along with SSIM we also measure the MSE ( Mean Square Error ) To know more about the SSIM technique Refer Here: https://en.wikipedia.org/wiki/Structural_similarity
Stars: ✭ 25 (-24.24%)
Mutual labels:  images
Cross
Cross++ Lightweight Crossplatform Game Engine
Stars: ✭ 26 (-21.21%)
Mutual labels:  lightweight
Lozad.js
🔥 Highly performant, light ~1kb and configurable lazy loader in pure JS with no dependencies for responsive images, iframes and more
Stars: ✭ 6,932 (+20906.06%)
Mutual labels:  images
Imgix.js
Responsive images in the browser, simplified
Stars: ✭ 922 (+2693.94%)
Mutual labels:  images
Its
image transformation service
Stars: ✭ 28 (-15.15%)
Mutual labels:  images
Image
A PHP library to handle images
Stars: ✭ 898 (+2621.21%)
Mutual labels:  images
Broken
Lightweight Unit Testing for C++
Stars: ✭ 8 (-75.76%)
Mutual labels:  lightweight
Jquery.lazy
A lightweight, fast, feature-rich, powerful and highly configurable delayed content, image and background lazy loading plugin for jQuery & Zepto.
Stars: ✭ 965 (+2824.24%)
Mutual labels:  images
Tator Native
Tator: The video and image annotator
Stars: ✭ 28 (-15.15%)
Mutual labels:  images
Ostrio Analytics
📊 Visitor's analytics tracking code for ostr.io service
Stars: ✭ 9 (-72.73%)
Mutual labels:  lightweight

onloaded

A tiny (350B) library to detect when images have loaded

Demo

This module exposes three module definitions:

  • ES Module: dist/onloaded.es.js
  • CommonJS: dist/onloaded.js
  • UMD: dist/onloaded.min.js

If using the UMD bundle, the library is exposed as onloaded globally.

Install

$ npm install --save onloaded

Usage

const onloaded = require('onloaded');

// passing a selector to `elem`
onloaded('#container > img', {
  onLoad(img) {
    img.className += ' loaded';
  },
  onError(img) {
    img.className += ' failed';
  },
  onProgress(val) {
    console.log(`I am ${ val * 100 }% complete!`);
  },
  onComplete(val, stats) {
    // val is always 1 ~~> 100%
    console.log('This callback always runs!');
    console.log(`  ${stats.loaded} loaded`);
    console.log(`  ${stats.failed} failed`);
    console.log(`  ${stats.total} total`);
  }
});

Note: Visit elem for other possibilities!

API

onloaded(elem, options)

elem

Type: String|Node|NodeList

You have several options here:

  1. Pass a selector string to img element(s);

    onloaded('.container img', { ... });
    
  2. Pass a reference to a specific <img /> DOM Node;

    var img = document.querySelector('.container img');
    onloaded(img, { ... });
    
  3. Pass a reference to a multiple <img /> DOM Nodes;

    var imgs = document.querySelectorAll('.container img');
    onloaded(imgs, { ... });
    
  4. Pass a reference to a container DOM Node that contains <img /> elements;

    var parent = document.querySelector('.container');
    onloaded(parent, { ... });
    

options.onError(node)

Type: Function

Callback whenever an image source failed to load. Receives the <img /> DOM node;

options.onLoad(node)

Type: Function

Callback whenever an image source sucessfully loads. Receives the <img /> DOM node;

options.onProgress(val, stats)

Type: Function

Callback whenever an image's network request has completed, regardless of success or failure.

Receives the current "progress" of completed requests as a decimal.

Also receives a stats object with loaded, failed, and total keys.

options.onComplete(val, stats)

Type: Function

Callback when all network requests have completed, regardless of success or failure.

Receives the "progress" as its first parameter. This will always equal 1.

Also receives a stats object with loaded, failed, and total keys.

License

MIT © Luke Edwards

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].