Skip to content

Commit

Permalink
fix: improved type definitions (#160)
Browse files Browse the repository at this point in the history
* Added better types for typescript

* Added missing cancel function
  • Loading branch information
Christian Stornowski authored and rigor789 committed Sep 17, 2019
1 parent 572a75f commit f6a6596
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions vue-scrollto.d.ts
@@ -1,36 +1,39 @@
import Vue, { DirectiveOptions, PluginObject } from "vue"
import {DirectiveOptions, PluginObject} from "vue"

type ElementDescriptor = Element | string

export interface ScrollOptions {
container?: ElementDescriptor
duration?: number
easing?: string
offset?: number
force?: boolean
cancelable?: boolean
onStart?: false | ((element: Element) => any)
onDone?: false | ((element: Element) => any)
onCancel?: false | ((event: Event, element: Element) => any)
x?: boolean
y?: boolean
el?: ElementDescriptor;
element?: ElementDescriptor;
container?: ElementDescriptor;
duration?: number;
easing?: string | [number, number, number, number];
offset?: number | ((element: ElementDescriptor, container: ElementDescriptor) => number);
force?: boolean;
cancelable?: boolean;
onStart?: ((element: Element) => any) | false;
onDone?: ((element: Element) => any) | false;
onCancel?: ((event: Event, element: Element) => any) | false;
x?: boolean;
y?: boolean;
}

type ScrollToFunction = (
element: ElementDescriptor,
duration?: number,
options?: ScrollOptions,
) => () => void
type ScrollToFunction = {
(options: ScrollOptions): () => void;
(element: ElementDescriptor, options?: ScrollOptions): () => void;
(element: ElementDescriptor, duration: number, options?: ScrollOptions): () => void;
}

declare const _default: PluginObject<ScrollOptions> &
DirectiveOptions & {
DirectiveOptions & {
scrollTo: ScrollToFunction
}
setDefaults: ScrollToFunction;
};

export default _default

declare module "vue/types/vue" {
interface Vue {
$scrollTo: ScrollToFunction
}
interface Vue {
$scrollTo: ScrollToFunction
}
}

0 comments on commit f6a6596

Please sign in to comment.