From a848da1c2975e66cb13739151d83cbfe55607362 Mon Sep 17 00:00:00 2001 From: AndersonFriaca Date: Sun, 10 Jun 2018 11:05:09 -0400 Subject: [PATCH] Types for JQuery Animate Scroll --- types/jquery-animate-scroll/index.d.ts | 24 ++++++++++++++++++ .../jquery-animate-scroll-tests.ts | 21 ++++++++++++++++ types/jquery-animate-scroll/tsconfig.json | 25 +++++++++++++++++++ types/jquery-animate-scroll/tslint.json | 1 + 4 files changed, 71 insertions(+) create mode 100644 types/jquery-animate-scroll/index.d.ts create mode 100644 types/jquery-animate-scroll/jquery-animate-scroll-tests.ts create mode 100644 types/jquery-animate-scroll/tsconfig.json create mode 100644 types/jquery-animate-scroll/tslint.json diff --git a/types/jquery-animate-scroll/index.d.ts b/types/jquery-animate-scroll/index.d.ts new file mode 100644 index 0000000000..a21b179738 --- /dev/null +++ b/types/jquery-animate-scroll/index.d.ts @@ -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 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +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; + } +} diff --git a/types/jquery-animate-scroll/jquery-animate-scroll-tests.ts b/types/jquery-animate-scroll/jquery-animate-scroll-tests.ts new file mode 100644 index 0000000000..65bdb07aef --- /dev/null +++ b/types/jquery-animate-scroll/jquery-animate-scroll-tests.ts @@ -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); diff --git a/types/jquery-animate-scroll/tsconfig.json b/types/jquery-animate-scroll/tsconfig.json new file mode 100644 index 0000000000..94883a5e7b --- /dev/null +++ b/types/jquery-animate-scroll/tsconfig.json @@ -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" + ] +} \ No newline at end of file diff --git a/types/jquery-animate-scroll/tslint.json b/types/jquery-animate-scroll/tslint.json new file mode 100644 index 0000000000..d04fe2e1fa --- /dev/null +++ b/types/jquery-animate-scroll/tslint.json @@ -0,0 +1 @@ +{"extends": "dtslint/dt.json"} \ No newline at end of file