diff --git a/types/vue-scrollto/index.d.ts b/types/vue-scrollto/index.d.ts new file mode 100644 index 0000000000..e20879473f --- /dev/null +++ b/types/vue-scrollto/index.d.ts @@ -0,0 +1,47 @@ +// Type definitions for vue-scrollto 2.7 +// Project: https://github.com/rigor789/vue-scrollto#readme +// Definitions by: Kovács Vince +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { PluginFunction } from "vue"; + +declare namespace VueScrollTo { + interface Options { + // The element you want to scroll to. + el?: string; + element?: string; + // The container that has to be scrolled. Default: body + container?: string; + // The duration (in milliseconds) of the scrolling animation. Default: 500 + duration?: number; + // The easing to be used when animating. Default: ease + easing?: string; + // The offset that should be applied when scrolling. Default: 0 + offset?: number; + // Indicates if user can cancel the scroll or not. Default: true + cancelable?: boolean; + // A callback function that should be called when scrolling has ended. Default: noop + onDone?: (() => void) | false; + // A callback function that should be called when scrolling has been aborted by the user (user scrolled, clicked + // etc.). Default: noop + onCancel?: (() => void) | false; + // Whether or not we want scrolling on the x axis. Default: true + x?: boolean; + // Whether or not we want scrolling on the y axis. Default: true + y?: boolean; + } +} + +declare class VueScrollTo { + static install: PluginFunction; + + scrollTo(element: string | HTMLElement, options?: VueScrollTo.Options): void; +} + +declare module "vue/types/vue" { + interface Vue { + $scrollTo: typeof VueScrollTo.prototype.scrollTo; + } +} + +export = VueScrollTo; diff --git a/types/vue-scrollto/package.json b/types/vue-scrollto/package.json new file mode 100644 index 0000000000..11da4f8ad5 --- /dev/null +++ b/types/vue-scrollto/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "vue": "^2.4.4" + } +} diff --git a/types/vue-scrollto/tsconfig.json b/types/vue-scrollto/tsconfig.json new file mode 100644 index 0000000000..6afe67dfcb --- /dev/null +++ b/types/vue-scrollto/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "vue-scrollto-tests.ts" + ] +} diff --git a/types/vue-scrollto/tslint.json b/types/vue-scrollto/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/vue-scrollto/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/vue-scrollto/vue-scrollto-tests.ts b/types/vue-scrollto/vue-scrollto-tests.ts new file mode 100644 index 0000000000..55b4d32305 --- /dev/null +++ b/types/vue-scrollto/vue-scrollto-tests.ts @@ -0,0 +1,11 @@ +import * as Vue from "vue"; +import * as VueScrollTo from "vue-scrollto"; + +Vue.use(VueScrollTo); + +class Test extends Vue { + mounted() { + this.$scrollTo(this.$el, {offset: -100}); + this.$scrollTo("#id"); + } +}