Merge pull request #19712 from plantain-00/lozad

add types of lozad
This commit is contained in:
Arthur Ozga
2017-09-14 14:03:32 -07:00
committed by GitHub
4 changed files with 64 additions and 0 deletions

25
types/lozad/index.d.ts vendored Normal file
View 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;

View 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
View 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
View File

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