Types for JQuery Animate Scroll

This commit is contained in:
AndersonFriaca
2018-06-10 11:05:09 -04:00
parent 42e514d82c
commit a848da1c29
4 changed files with 71 additions and 0 deletions

24
types/jquery-animate-scroll/index.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
// Type definitions for JQuery Animate Scroll 1.0
// Project: https://github.com/risan/jquery-animate-scroll
// Definitions by: Anderson Friaça <https://github.com/AndersonFriaca>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery" />
export type Options = Partial<{
$container: JQuery;
speed: number;
offset: number;
}>;
declare global {
interface JQuery {
animateScroll(options?: Options): JQuery;
scrollHere(options?: Options): JQuery;
}
interface JQueryStatic {
scrollTo(element: JQuery, options?: Options): void;
}
}

View File

@@ -0,0 +1,21 @@
import { Options } from "jquery-animate-scroll";
// basic usage
$('a').animateScroll();
$('#article-1').scrollHere();
$.scrollTo($('#article-1'));
// with options
const options: Options = {
$container: $('body'),
speed: 1000,
offset: -100
};
$('a').animateScroll(options);
$('#article-1').scrollHere(options);
$.scrollTo($('#article-1'), options);

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"jquery-animate-scroll-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{"extends": "dtslint/dt.json"}