Merge pull request #23747 from AndersonFriaca/jquery-lazyload

Types for jquery-lazyload
This commit is contained in:
Daniel Rosenwasser
2018-02-19 10:57:49 -08:00
committed by GitHub
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"}