Skip to content

Commit

Permalink
feat: add typescript bindings (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaSemenov authored and rigor789 committed Sep 16, 2019
1 parent e82c42b commit 1b39aaf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0-development",
"description": "Adds a directive that listens for click events and scrolls to elements.",
"main": "vue-scrollto.js",
"types": "vue-scrollto.d.ts",
"keywords": [
"vue",
"vuejs",
Expand Down
36 changes: 36 additions & 0 deletions vue-scrollto.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Vue, { 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
}

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

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

export default _default

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

0 comments on commit 1b39aaf

Please sign in to comment.