-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from biluochun/master
add types
- Loading branch information
Showing
6 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import "./vue"; | ||
import { VueLazyloadPluginObject } from "./lazyload"; | ||
|
||
declare var VueLazyload: VueLazyloadPluginObject; | ||
export default VueLazyload; | ||
|
||
export { | ||
VueLazyloadImage, | ||
VueLazyloadOptions, | ||
VueLazyloadHandler, | ||
VueReactiveListener | ||
} from "./lazyload"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { PluginObject } from "vue"; | ||
|
||
interface IntersectionObserverInit { | ||
root?: Element | null; | ||
rootMargin?: string; | ||
threshold?: number | number[]; | ||
} | ||
|
||
export interface VueLazyloadImage { | ||
src: string; | ||
error?: string; | ||
loading?: string; | ||
} | ||
|
||
export interface VueLazyloadOptions { | ||
lazyComponent?: boolean; | ||
preLoad?: number; | ||
error?: string; | ||
loading?: string; | ||
attempt?: number; | ||
listenEvents?: string[]; | ||
adapter?: any; | ||
filter?: any; | ||
dispatchEvent?: boolean; | ||
throttleWait?: number; | ||
observer?: boolean; | ||
observerOptions?: IntersectionObserverInit; | ||
silent?: boolean; | ||
preLoadTop?: number; | ||
scale?: number; | ||
hasbind?: boolean; | ||
} | ||
|
||
export interface VueReactiveListener { | ||
el: Element; | ||
src: string; | ||
error: string; | ||
loading: string; | ||
bindType: string; | ||
attempt: number; | ||
naturalHeight: number; | ||
naturalWidth: number; | ||
options: VueLazyloadOptions; | ||
rect: DOMRect; | ||
$parent: Element | ||
elRenderer: Function; | ||
performanceData: { | ||
init: number, | ||
loadStart: number, | ||
loadEnd: number | ||
}; | ||
} | ||
|
||
export interface VueLazyloadListenEvent { | ||
(listener: VueReactiveListener, cache: boolean) : void; | ||
} | ||
|
||
export interface VueLazyloadHandler { | ||
$on (event: string, callback: VueLazyloadListenEvent): void; | ||
$once (event: string, callback: VueLazyloadListenEvent): void; | ||
$off (event: string, callback?: VueLazyloadListenEvent): void; | ||
lazyLoadHandler (): void; | ||
} | ||
|
||
export interface VueLazyloadPluginObject extends PluginObject<VueLazyloadOptions> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Vue from "vue"; | ||
import VueLazyload, { VueLazyloadOptions } from "../index"; | ||
|
||
Vue.use<VueLazyloadOptions>(VueLazyload); | ||
|
||
Vue.use<VueLazyloadOptions>(VueLazyload, { | ||
preLoad: 0, | ||
}); | ||
|
||
const vm = new Vue({}); | ||
|
||
vm.$Lazyload.lazyLoadHandler(); | ||
vm.$Lazyload.$on('loading', function (state, cache) { | ||
const err: string = state.error; | ||
const el: Element = state.el; | ||
const bol: boolean = cache; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "es2015", | ||
"moduleResolution": "node", | ||
"lib": [ | ||
"es5", | ||
"dom", | ||
"es2015.promise", | ||
"es2015.core" | ||
], | ||
"strict": true, | ||
"noEmit": true | ||
}, | ||
"include": [ | ||
"*.ts", | ||
"../*.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Augment the typings of Vue.js | ||
*/ | ||
|
||
import Vue from "vue"; | ||
import { VueLazyloadHandler } from "./index"; | ||
|
||
declare module "vue/types/vue" { | ||
interface Vue { | ||
$Lazyload: VueLazyloadHandler; | ||
} | ||
} | ||
|