Skip to content
Permalink
Browse files

fix: improved type definitions (#160)

* Added better types for typescript

* Added missing cancel function
  • Loading branch information...
ChristianStornowski authored and rigor789 committed Sep 17, 2019
1 parent 572a75f commit f6a6596815ec5beeb57c404de1ad4a30a645cd94
Showing with 25 additions and 22 deletions.
  1. +25 −22 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.
You can’t perform that action at this time.