mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 14:59:37 +08:00
25
types/lozad/index.d.ts
vendored
Normal file
25
types/lozad/index.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Type definitions for lozad 1.0
|
||||
// Project: https://github.com/ApoorvSaxena/lozad.js
|
||||
// Definitions by: York Yao <https://github.com/plantain-00>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Option {
|
||||
rootMargin?: string;
|
||||
threshold?: number;
|
||||
load?(element: HTMLElement | HTMLCanvasElement): void;
|
||||
}
|
||||
|
||||
interface Observer {
|
||||
observe(): void;
|
||||
}
|
||||
|
||||
declare function lozad(selector?: string, options?: Option): Observer;
|
||||
|
||||
declare namespace lozad {
|
||||
const prototype: {
|
||||
};
|
||||
}
|
||||
|
||||
export as namespace lozad;
|
||||
|
||||
export = lozad;
|
||||
13
types/lozad/lozad-tests.ts
Normal file
13
types/lozad/lozad-tests.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import lozad = require('lozad');
|
||||
|
||||
const observer = lozad('.lozad', {
|
||||
rootMargin: '10px 0px', // syntax similar to that of CSS Margin
|
||||
threshold: 0.1, // ratio of element convergence
|
||||
load(el) {
|
||||
console.log('loading element');
|
||||
|
||||
// Custom implementation to load an element
|
||||
// e.g. el.src = el.dataset.src;
|
||||
}
|
||||
});
|
||||
observer.observe();
|
||||
23
types/lozad/tsconfig.json
Normal file
23
types/lozad/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"lozad-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/lozad/tslint.json
Normal file
3
types/lozad/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user