diff --git a/react-smooth-scrollbar/index.d.ts b/react-smooth-scrollbar/index.d.ts new file mode 100644 index 0000000000..3c4d541294 --- /dev/null +++ b/react-smooth-scrollbar/index.d.ts @@ -0,0 +1,40 @@ +// Type definitions for react-smooth-scrollbar 7.2 +// Project: https://github.com/idiotWu/react-smooth-scrollbar +// Definitions by: Alexey Svetliakov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from "react"; +import SmoothScrollbar, { ScrollbarOptions, ScrollStatusObject } from "smooth-scrollbar"; + +declare namespace Scrollbar { + interface ScrollbarProps extends ScrollbarOptions { + /** + * Pipe to scrollbar.addListener() + */ + onScroll?: (status: ScrollStatusObject, scrollbarInstance: SmoothScrollbar) => void; + /** + * Keep scrollbar tracks visible whether it's scrolling or not + * @default false + */ + alwaysShowTracks?: boolean; + /** + * Optional class name + */ + className?: string; + /** + * Optional style + */ + style?: React.CSSProperties; + } +} + +declare class Scrollbar extends React.Component { + /** + * Scrollbar instance + */ + public readonly scrollbar: SmoothScrollbar; + +} + +export as namespace Scrollbar; +export = Scrollbar; diff --git a/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx b/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx new file mode 100644 index 0000000000..f46efe0e62 --- /dev/null +++ b/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx @@ -0,0 +1,19 @@ +import * as React from "react"; +import * as SmoothScrollbar from "react-smooth-scrollbar"; + + { } } />; +; + +class Test extends React.Component { + public ref: SmoothScrollbar; + + public componentDidMount() { + this.ref.scrollbar.scrollTo(0, 500); + } + + public render() { + return ( + this.ref = ref} /> + ); + } +} diff --git a/react-smooth-scrollbar/tsconfig.json b/react-smooth-scrollbar/tsconfig.json new file mode 100644 index 0000000000..aef8e9bced --- /dev/null +++ b/react-smooth-scrollbar/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-smooth-scrollbar-tests.tsx" + ] +} diff --git a/react-smooth-scrollbar/tslint.json b/react-smooth-scrollbar/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-smooth-scrollbar/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }