Skip to content

Commit 1b39aaf

Browse files
IlyaSemenovrigor789
authored andcommitted
feat: add typescript bindings (#159)
1 parent e82c42b commit 1b39aaf

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.0-development",
44
"description": "Adds a directive that listens for click events and scrolls to elements.",
55
"main": "vue-scrollto.js",
6+
"types": "vue-scrollto.d.ts",
67
"keywords": [
78
"vue",
89
"vuejs",

vue-scrollto.d.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import Vue, { DirectiveOptions, PluginObject } from "vue"
2+
3+
type ElementDescriptor = Element | string
4+
5+
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
17+
}
18+
19+
type ScrollToFunction = (
20+
element: ElementDescriptor,
21+
duration?: number,
22+
options?: ScrollOptions,
23+
) => () => void
24+
25+
declare const _default: PluginObject<ScrollOptions> &
26+
DirectiveOptions & {
27+
scrollTo: ScrollToFunction
28+
}
29+
30+
export default _default
31+
32+
declare module "vue/types/vue" {
33+
interface Vue {
34+
$scrollTo: ScrollToFunction
35+
}
36+
}

0 commit comments

Comments
 (0)