mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Add imagesloaded once event listener and config to ctor (#15091)
Documented at http://imagesloaded.desandro.com/#vanilla-javascript
This commit is contained in:
committed by
Mohamed Hegazy
parent
1c48132fce
commit
a08cfaa635
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
function test_ctor() {
|
||||
// element
|
||||
imagesLoaded(document.querySelector('#container'), function(instance) {
|
||||
@@ -12,6 +10,14 @@ function test_ctor() {
|
||||
// multiple elements
|
||||
var posts = document.querySelectorAll('.post');
|
||||
imagesLoaded(posts, function() { console.log('all images are loaded'); });
|
||||
|
||||
// options
|
||||
imagesLoaded('#container', { background: true }, function() {
|
||||
console.log('all images are loaded');
|
||||
});
|
||||
imagesLoaded('#container', { background: '.item' }, function() {
|
||||
console.log('all images are loaded');
|
||||
});
|
||||
}
|
||||
|
||||
function test_events_basic() {
|
||||
@@ -25,6 +31,8 @@ function test_events_basic() {
|
||||
imgLoad.on('always', onAlways);
|
||||
// unbind with .off()
|
||||
imgLoad.off('always', onAlways);
|
||||
// bind once with .once()
|
||||
imgLoad.once('always', onAlways);
|
||||
}
|
||||
|
||||
function test_events_full() {
|
||||
|
||||
Vendored
+10
-3
@@ -1,9 +1,9 @@
|
||||
// Type definitions for imagesLoaded 3.1.8
|
||||
// Type definitions for imagesLoaded 4.1.1
|
||||
// Project: https://github.com/desandro/imagesloaded
|
||||
// Definitions by: Chris Charabaruk <http://github.com/coldacid>
|
||||
// Definitions by: Chris Charabaruk <https://github.com/coldacid>, Cameron Little <https://github.com/apexskier>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference types="jquery" />
|
||||
/// <reference types="jquery" />
|
||||
|
||||
declare namespace ImagesLoaded {
|
||||
type ElementSelector = Element | NodeList | Array<Element> | string;
|
||||
@@ -30,14 +30,21 @@ declare namespace ImagesLoaded {
|
||||
// event listeners
|
||||
on(event: string, listener: ImagesLoadedListener): void;
|
||||
off(event: string, listener: ImagesLoadedListener): void;
|
||||
once(event: string, listener: ImagesLoadedListener): void;
|
||||
}
|
||||
|
||||
interface ImagesLoadedOptions {
|
||||
background: true | string;
|
||||
}
|
||||
|
||||
interface ImagesLoadedConstructor {
|
||||
/**
|
||||
* Creates a new ImagesLoaded object with the provided callback
|
||||
* @param elem Element, NodeList, Element array, or selector string for images to watch
|
||||
* @param options object that can tell imagesloaded to watch background images as well
|
||||
* @param callback function triggered after all images have been loaded
|
||||
*/
|
||||
(elem: ElementSelector, options: ImagesLoadedOptions, callback?: ImagesLoadedCallback): ImagesLoaded;
|
||||
(elem: ElementSelector, callback?: ImagesLoadedCallback): ImagesLoaded;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user