Skip to content

Commit 0ab7e28

Browse files
authored
Merge pull request #8 from TedDriggs/typescript-types
Add typescript declarations
2 parents 802042d + d982b8a commit 0ab7e28

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

index.d.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { Component, CSSProperties, SFC } from "react";
2+
3+
export interface ScrollbarRendererProps {
4+
className?: string | string[];
5+
style?: CSSProperties;
6+
}
7+
8+
export interface ScrollValues {
9+
scrollTop: number;
10+
scrollLeft: number;
11+
scrollHeight: number;
12+
scrollWidth: number;
13+
clientHeight: number;
14+
clientWidth: number;
15+
}
16+
17+
export interface ScrollbarProps {
18+
minimalThumbsSize?: number;
19+
fallbackScrollbarWidth?: number;
20+
21+
rtl?: boolean;
22+
momentum?: boolean;
23+
defaultStyles?: boolean;
24+
25+
permanentScrollbars?: boolean;
26+
permanentScrollbarX?: boolean;
27+
permanentScrollbarY?: boolean;
28+
29+
noScroll?: boolean;
30+
noScrollX?: boolean;
31+
noScrollY?: boolean;
32+
33+
tagName?: string;
34+
35+
className?: string | string[];
36+
wrapperClassName?: string | string[];
37+
contentClassName?: string | string[];
38+
trackVerticalClassName?: string | string[];
39+
trackHorizontalClassName?: string | string[];
40+
thumbVerticalClassName?: string | string[];
41+
thumbHorizontalClassName?: string | string[];
42+
43+
style?: CSSProperties;
44+
wrapperStyle?: CSSProperties;
45+
contentStyle?: CSSProperties;
46+
trackVerticalStyle?: CSSProperties;
47+
trackHorizontalStyle?: CSSProperties;
48+
thumbVerticalStyle?: CSSProperties;
49+
thumbHorizontalStyle?: CSSProperties;
50+
51+
onScroll?(current: ScrollValues, instance: Scrollbar): void;
52+
onScrollStart?(instance: Scrollbar): void;
53+
onScrollStop?(instance: Scrollbar): void;
54+
scrollDetectionThreshold?: number;
55+
56+
renderWrapper?: SFC<ScrollbarRendererProps>;
57+
renderContent?: SFC<ScrollbarRendererProps>;
58+
renderTrackVertical?: SFC<ScrollbarRendererProps>;
59+
renderTrackHorizontal?: SFC<ScrollbarRendererProps>;
60+
renderThumbVertical?: SFC<ScrollbarRendererProps>;
61+
renderThumbHorizontal?: SFC<ScrollbarRendererProps>;
62+
}
63+
64+
declare class Scrollbar extends Component<ScrollbarProps> {
65+
public scrollTop: number;
66+
public scrollLeft: number;
67+
public readonly scrollHeight: number;
68+
public readonly scrollWidth: number;
69+
public readonly clientHeight: number;
70+
public readonly clientWidth: number;
71+
/**
72+
* Scroll to the top border.
73+
*
74+
* @returns The scrollbar instance
75+
*/
76+
public scrollToTop(): Scrollbar;
77+
/**
78+
* Scroll to the bottom border.
79+
*
80+
* @returns The scrollbar instance
81+
*/
82+
public scrollToBottom(): Scrollbar;
83+
/**
84+
* Scroll to the left border.
85+
*
86+
* @returns The scrollbar instance
87+
*/
88+
public scrollToLeft(): Scrollbar;
89+
/**
90+
* Scroll to the right border.
91+
*
92+
* @returns The scrollbar instance
93+
*/
94+
public scrollToRight(): Scrollbar;
95+
/**
96+
* Updates the scrollbars. By default, this does nothing if content and
97+
* wrapper sizes are unchanged.
98+
*
99+
* @param forced Whether to update the scrollbars even if nothing changed.
100+
* @param rtlAutodetect Whether to check CSS direction value.
101+
*
102+
* @returns The scrollbar instance.
103+
*/
104+
public update(forced?: boolean, rtlAutodetect?: boolean): Scrollbar;
105+
}
106+
107+
export default Scrollbar;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"description": "The best React custom scrollbars component",
44
"version": "2.1.3",
55
"main": "dist/index.js",
6+
"types": "index.d.ts",
67
"repository": {
78
"type": "git",
89
"url": "https://github.com/xobotyi/react-scrollbars-custom.git"

0 commit comments

Comments
 (0)