diff --git a/types/jquery-lazyload/index.d.ts b/types/jquery-lazyload/index.d.ts new file mode 100644 index 0000000000..5505c247f5 --- /dev/null +++ b/types/jquery-lazyload/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for JQuery Lazy Load 1.9 +// Project: https://github.com/tuupola/jquery_lazyload +// Definitions by: Anderson Friaça +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +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; +} diff --git a/types/jquery-lazyload/jquery-lazyload-tests.ts b/types/jquery-lazyload/jquery-lazyload-tests.ts new file mode 100644 index 0000000000..086069d11d --- /dev/null +++ b/types/jquery-lazyload/jquery-lazyload-tests.ts @@ -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"); + }); +}); diff --git a/types/jquery-lazyload/tsconfig.json b/types/jquery-lazyload/tsconfig.json new file mode 100644 index 0000000000..857bd1b9f5 --- /dev/null +++ b/types/jquery-lazyload/tsconfig.json @@ -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" + ] +} \ No newline at end of file diff --git a/types/jquery-lazyload/tslint.json b/types/jquery-lazyload/tslint.json new file mode 100644 index 0000000000..d04fe2e1fa --- /dev/null +++ b/types/jquery-lazyload/tslint.json @@ -0,0 +1 @@ +{"extends": "dtslint/dt.json"} \ No newline at end of file