Skip to content

chore: improve types definition #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,51 @@
// Definitions by: Phil Scott <https://github.com/enkafan>
// PeachScript <https://github.com/PeachScript>

import Vue, { VNode } from 'vue';

declare namespace InfiniteLoading {
type SpinnerType = 'default' | 'bubbles' | 'circles' | 'spiral' | 'waveDots';

type DirectionType = 'top' | 'bottom';

interface Slots {
spinner: VNode[];
'no-result': VNode[];
'no-more': VNode[];
[key: string]: VNode[];
}
import Vue, { VNode } from "vue";

export type SpinnerType =
| "default"
| "bubbles"
| "circles"
| "spiral"
| "waveDots";

export type DirectionType = "top" | "bottom";

export interface Slots {
spinner: VNode[];
"no-result": VNode[];
"no-more": VNode[];
[key: string]: VNode[];
}

interface StateChanger {
loaded(): void;
complete(): void;
reset(): void;
}
export interface StateChanger {
loaded(): void;
complete(): void;
reset(): void;
}

declare class InfiniteLoading extends Vue {
// The trigger distance
distance: number;

// The load spinner type
spinner: InfiniteLoading.SpinnerType;
spinner: SpinnerType;

// The scroll direction
direction: InfiniteLoading.DirectionType;
direction: DirectionType;

// Whether find the element which has `infinite-wrapper` attribute as the scroll wrapper
forceUseInfiniteWrapper: boolean;

// Infinite event handler
onInfinite: ($state: InfiniteLoading.StateChanger) => void;
onInfinite: ($state: StateChanger) => void;

// The method collection used to change infinite state
stateChanger: InfiniteLoading.StateChanger;
stateChanger: StateChanger;

// Slots
$slots: InfiniteLoading.Slots;
$slots: Slots;
}

export default InfiniteLoading;