[vue-scrollto] Add definition (#20346)

* Add vue-scroll typings

* Fix tslint errors

* Fix import vue package

* Fix reference

* Add vue depencency to package.json

* remove redundant export

* Unnecessary to import Vue

* Remove node reference

* Add dom to libraries

* Fix tslint errors
This commit is contained in:
Kovács Vince
2017-10-09 15:49:24 -07:00
committed by Wesley Wigham
parent 874881be27
commit 21badac033
5 changed files with 88 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
// Type definitions for vue-scrollto 2.7
// Project: https://github.com/rigor789/vue-scrollto#readme
// Definitions by: Kovács Vince <https://github.com/vincekovacs>
// 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<never>;
scrollTo(element: string | HTMLElement, options?: VueScrollTo.Options): void;
}
declare module "vue/types/vue" {
interface Vue {
$scrollTo: typeof VueScrollTo.prototype.scrollTo;
}
}
export = VueScrollTo;
+6
View File
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"vue": "^2.4.4"
}
}
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+11
View File
@@ -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");
}
}