@codog/vue3-infinite-loading
Version:
An infinite scroll plugin for Vue.js
77 lines • 2.56 kB
TypeScript
import { App, ComponentPublicInstance } from 'vue';
export interface PluginOptions {
props?: Partial<InfiniteLoadingProps>;
slots?: Partial<InfiniteLoadingSlots>;
system?: Partial<InfiniteLoadingSystem>;
}
export interface InfiniteLoadingProps {
/** Distance from the bottom to trigger loading */
distance: number;
/** Spinner type */
spinner: string;
/** Loading direction */
direction: 'top' | 'bottom';
/** Force use infinite wrapper */
forceUseInfiniteWrapper: boolean | string;
/** Identifier for resetting */
identifier: number | string;
/** Infinite loading callback */
onInfinite?: (stateChanger: StateChanger) => void;
}
export interface InfiniteLoadingSlots {
/** No results message */
noResults: string | ComponentPublicInstance;
/** No more data message */
noMore: string | ComponentPublicInstance;
/** Error message */
error: string | ComponentPublicInstance;
/** Error button text */
errorBtnText: string;
/** Spinner component */
spinner: string | ComponentPublicInstance;
}
export interface InfiniteLoadingSystem {
/** Throttle limit in milliseconds */
throttleLimit: number;
/** Loop check timeout in milliseconds */
loopCheckTimeout: number;
/** Max allowed continuous calls */
loopCheckMaxCalls: number;
}
export interface StateChanger {
/** Mark loading as complete */
loaded: () => void;
/** Mark loading as finished */
complete: () => void;
/** Reset loading state */
reset: () => void;
/** Mark loading as error */
error: () => void;
}
export declare enum LoadingStatus {
READY = 0,
LOADING = 1,
COMPLETE = 2,
ERROR = 3
}
export type SpinnerType = 'default' | 'spiral' | 'bubbles' | 'circles' | 'wave-dots';
export interface InfiniteLoadingInstance extends ComponentPublicInstance {
/** Current loading status */
status: LoadingStatus;
/** Whether this is the first load */
isFirstLoad: boolean;
/** Attempt to load more data */
attemptLoad: (isContinuousCall?: boolean) => void;
/** Get current distance from trigger point */
getCurrentDistance: () => number;
/** Get scroll parent element */
getScrollParent: (elm?: Element) => Element | Window;
}
export interface InfiniteLoadingPlugin {
install: (app: App, options?: PluginOptions) => void;
}
export interface InfiniteLoadingEvents {
/** Triggered when loading starts */
infinite: (stateChanger: StateChanger) => void;
}
//# sourceMappingURL=index.d.ts.map