Skip to content

Commit f6a6596

Browse files
Christian Stornowskirigor789
Christian Stornowski
authored andcommitted
fix: improved type definitions (#160)
* Added better types for typescript * Added missing cancel function
1 parent 572a75f commit f6a6596

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

vue-scrollto.d.ts

+25-22
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
1-
import Vue, { DirectiveOptions, PluginObject } from "vue"
1+
import {DirectiveOptions, PluginObject} from "vue"
22

33
type ElementDescriptor = Element | string
44

55
export interface ScrollOptions {
6-
container?: ElementDescriptor
7-
duration?: number
8-
easing?: string
9-
offset?: number
10-
force?: boolean
11-
cancelable?: boolean
12-
onStart?: false | ((element: Element) => any)
13-
onDone?: false | ((element: Element) => any)
14-
onCancel?: false | ((event: Event, element: Element) => any)
15-
x?: boolean
16-
y?: boolean
6+
el?: ElementDescriptor;
7+
element?: ElementDescriptor;
8+
container?: ElementDescriptor;
9+
duration?: number;
10+
easing?: string | [number, number, number, number];
11+
offset?: number | ((element: ElementDescriptor, container: ElementDescriptor) => number);
12+
force?: boolean;
13+
cancelable?: boolean;
14+
onStart?: ((element: Element) => any) | false;
15+
onDone?: ((element: Element) => any) | false;
16+
onCancel?: ((event: Event, element: Element) => any) | false;
17+
x?: boolean;
18+
y?: boolean;
1719
}
1820

19-
type ScrollToFunction = (
20-
element: ElementDescriptor,
21-
duration?: number,
22-
options?: ScrollOptions,
23-
) => () => void
21+
type ScrollToFunction = {
22+
(options: ScrollOptions): () => void;
23+
(element: ElementDescriptor, options?: ScrollOptions): () => void;
24+
(element: ElementDescriptor, duration: number, options?: ScrollOptions): () => void;
25+
}
2426

2527
declare const _default: PluginObject<ScrollOptions> &
26-
DirectiveOptions & {
28+
DirectiveOptions & {
2729
scrollTo: ScrollToFunction
28-
}
30+
setDefaults: ScrollToFunction;
31+
};
2932

3033
export default _default
3134

3235
declare module "vue/types/vue" {
33-
interface Vue {
34-
$scrollTo: ScrollToFunction
35-
}
36+
interface Vue {
37+
$scrollTo: ScrollToFunction
38+
}
3639
}

0 commit comments

Comments
 (0)