diff --git a/types/jquery.nicescroll/index.d.ts b/types/jquery.nicescroll/index.d.ts new file mode 100644 index 0000000000..8228ae5209 --- /dev/null +++ b/types/jquery.nicescroll/index.d.ts @@ -0,0 +1,105 @@ +// Type definitions for jquery.nicescroll 3.7 +// Project: https://nicescroll.areaaperta.com +// Definitions by: Bohdan Stupak +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +declare namespace JQueryNiceScroll { + interface NiceScrollPage { + maxw: number; + maxh: number; + width: number; + height: number; + w: number; + h: number; + } + + interface NiceScroll { + show(): NiceScroll; + hide(): NiceScroll; + toggle(): NiceScroll; + onResize(e?: Event, page?: NiceScrollPage): NiceScroll; + resize(e?: Event, page?: NiceScrollPage): NiceScroll; + remove(): void; + stop(): NiceScroll; + doScrollPos(x: number, y: number, spd: number): void; + doScrollLeft(x: number, duration: number): void; + doScrollTop(x: number, duration: number): void; + } + + interface NiceScrollOptions { + zindex?: "auto" | number; + cursoropacitymin?: number; + cursoropacitymax?: number; + cursorcolor?: string; + cursorwidth?: string; + cursorborder?: string; + cursorborderradius?: string; + scrollspeed?: number; + mousescrollstep?: number; + touchbehavior?: boolean; + emulatetouch?: boolean; + hwacceleration?: boolean; + usetransition?: boolean; + boxzoom?: boolean; + dblclickzoom?: boolean; + gesturezoom?: boolean; + grabcursorenabled?: boolean; + autohidemode?: "leave" | "scroll" | "cursor" | "hidden" | boolean; + background?: string; + iframeautoresize?: boolean; + cursorminheight?: number; + preservenativescrolling?: boolean; + railoffset?: boolean | { + top?: number; + left?: number; + }; + railhoffset?: boolean | { + top?: number; + left?: number; + }; + bouncescroll?: boolean; + spacebarenabled?: boolean; + railpadding?: { + top: number; + right: number; + left: number; + bottom: number; + }; + disableoutline?: boolean; + horizrailenabled?: boolean; + railalign?: "right" | "left" | "top" | "bottom"; + railvalign?: "right" | "left" | "top" | "bottom"; + enabletranslate3d?: boolean; + enablemousewheel?: boolean; + enablekeyboard?: boolean; + smoothscroll?: boolean; + sensitiverail?: boolean; + enablemouselockapi?: boolean; + cursorfixedheight?: number; + directionlockdeadzone?: number; + hidecursordelay?: number; + nativeparentscrolling?: boolean; + enablescrollonselection?: boolean; + overflowx?: "auto" | "hidden" | "inherit" | "initial" | "overlay" | "scroll" | "unset" | "visible"; + overflowy?: "auto" | "hidden" | "inherit" | "initial" | "overlay" | "scroll" | "unset" | "visible"; + cursordragspeed?: number; + rtlmode?: "auto" | boolean; + cursordragontouch?: boolean; + oneaxismousemode?: "auto" | boolean; + scriptpath?: string; + preventmultitouchscrolling?: boolean; + disablemutationobserver?: boolean; + enableobserver?: boolean; + scrollbarid?: string; + scrollCLass?: string; + } +} + +interface JQuery { + niceScroll(options?: JQueryNiceScroll.NiceScrollOptions): JQueryNiceScroll.NiceScroll; + niceScroll(wrapper: string, options: JQueryNiceScroll.NiceScrollOptions): JQueryNiceScroll.NiceScroll; + getNiceScroll(index?: number): JQueryNiceScroll.NiceScroll; +} diff --git a/types/jquery.nicescroll/jquery.nicescroll-tests.ts b/types/jquery.nicescroll/jquery.nicescroll-tests.ts new file mode 100644 index 0000000000..f4362530f9 --- /dev/null +++ b/types/jquery.nicescroll/jquery.nicescroll-tests.ts @@ -0,0 +1,41 @@ +// cases from documentation +// 1. Simple mode, it styles document scrollbar: +$(() => { + $("body").niceScroll(); +}); + +// 2. Instance with object returned: +let nice; +$(() => { + nice = $("body").niceScroll(); +}); + +// 3. Style a DIV and change cursor color: +$(() => { + $("#thisdiv").niceScroll({cursorcolor: "#00F"}); +}); + +// 4. DIV with "wrapper", formed by two divs, the first is the vieport, the latter is the content: +$(() => { + $("#viewportdiv").niceScroll("#wrapperdiv", {cursorcolor: "#00F"}); +}); + +// 5. Get nicescroll object: +nice = $("#mydiv").getNiceScroll(); + +// 6. Hide scrollbars: +$("#mydiv").getNiceScroll().hide(); + +// 7. Check for scrollbars resize (when content or position have changed): +$("#mydiv").getNiceScroll().resize(); + +// 8. Scrolling to a position: +$("#mydiv").getNiceScroll(0).doScrollLeft(1, 2); // Scroll X Axis +$("#mydiv").getNiceScroll(0).doScrollTop(1, 14); // Scroll Y Axis + +// other cases +$(".ui-grid-viewport").niceScroll({ + cursorcolor: "#fff", + cursorwidth: "8px", + autohidemode: "leave" +}); diff --git a/types/jquery.nicescroll/tsconfig.json b/types/jquery.nicescroll/tsconfig.json new file mode 100644 index 0000000000..9d94444fc2 --- /dev/null +++ b/types/jquery.nicescroll/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery.nicescroll-tests.ts" + ] +} \ No newline at end of file diff --git a/types/jquery.nicescroll/tslint.json b/types/jquery.nicescroll/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/jquery.nicescroll/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file