Types for jquery-lazyload

This commit is contained in:
AndersonFriaca
2018-02-17 23:15:03 -03:00
parent 628c63919c
commit 322d589b4e
4 changed files with 72 additions and 0 deletions

26
types/jquery-lazyload/index.d.ts vendored Normal file
View File

@@ -0,0 +1,26 @@
// Type definitions for jQuery Lazy Load 1.9
// Project: https://github.com/tuupola/jquery_lazyload
// Definitions by: Anderson Friaça <https://github.com/AndersonFriaca>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery" />
declare namespace jQueryLazyLoad {
interface Options {
threshold?: number;
failure_limit?: number;
event?: string;
effect?: string;
container?: JQuery;
data_attribute?: string;
skip_invisible?: boolean;
appear?: null;
load?: (elementsLeft?: number, options?: Options) => void;
placeholder?: string;
}
}
interface JQuery {
lazyload(options?: jQueryLazyLoad.Options): JQuery;
on(event: 'load', callback: ((options?: jQueryLazyLoad.Options) => void)): JQuery;
}

View File

@@ -0,0 +1,20 @@
$(document).ready(() => {
// basic usage
$('.lazyload').lazyload();
// with options
const options: jQueryLazyLoad.Options = {
threshold: 200,
event: 'click',
effect: 'fadeIn',
container: $('#container'),
failure_limit: 10,
skip_invisible: true
};
$('.lazyload').lazyload(options);
// event on load
$('.lazyload').on('load', () => {
$("img.lazy").trigger("click");
});
});

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"jquery-lazyload-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{"extends": "dtslint/dt.json"}