diff --git a/packages/vant-lazyload/package.json b/packages/vant-lazyload/package.json index d8c4b56f9..8084bfe0e 100644 --- a/packages/vant-lazyload/package.json +++ b/packages/vant-lazyload/package.json @@ -4,7 +4,7 @@ "description": "This is a fork of vue-lazyload", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", - "types": "dist/index.d.ts", + "types": "types/index.d.ts", "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" diff --git a/packages/vant-lazyload/types/index.d.ts b/packages/vant-lazyload/types/index.d.ts new file mode 100644 index 000000000..e6415ec16 --- /dev/null +++ b/packages/vant-lazyload/types/index.d.ts @@ -0,0 +1,45 @@ +import { App } from 'vue'; + +declare type ListenEvent = + | 'scroll' + | 'wheel' + | 'mousewheel' + | 'resize' + | 'animationend' + | 'transitionend' + | 'touchmove'; + +// eslint-disable-next-line +declare type Callback = (listener: any, options: LazyloadOptions) => void; + +declare type Filter = { + webp?: Callback; + progressive?: Callback; +}; + +declare type Adapter = { + error?: Callback; + loaded?: Callback; + loading?: Callback; +}; + +export declare type LazyloadOptions = { + error?: string; + filter?: Filter; + silent?: boolean; + adapter?: Adapter; + loading?: string; + attempt?: number; + preLoad?: number; + observer?: boolean; + lazyImage?: boolean; + throttleWait?: number; + listenEvents?: ListenEvent[]; + dispatchEvent?: boolean; + lazyComponent?: boolean; + observerOptions?: IntersectionObserverInit; +}; + +export declare const Lazyload: { + install(app: App, options?: LazyloadOptions): void; +};