@ehfuse/overlay-scrollbar 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 KIM YOUNG JIN
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,223 @@
1
+ # OverlayScrollbar
2
+
3
+ A React component that provides a custom overlay scrollbar with smooth animations and auto-hide functionality.
4
+
5
+ ## πŸ“š Documentation
6
+
7
+ - **[Getting Started (English)](https://github.com/ehfuse/overlay-scrollbar/blob/main/docs/getting-started-en.md)** - Complete setup and usage guide
8
+ - **[μ‹œμž‘ν•˜κΈ° (ν•œκ΅­μ–΄)](https://github.com/ehfuse/overlay-scrollbar/blob/main/docs/getting-started-ko.md)** - μ„€μΉ˜ 및 μ‚¬μš©λ²• κ°€μ΄λ“œ
9
+
10
+ ## Features
11
+
12
+ - 🎨 **Custom styled scrollbar** - Beautiful overlay scrollbar that doesn't take up content space
13
+ - ⚑ **Smooth animations** - Smooth fade-in/out transitions with customizable timing
14
+ - πŸ” **Auto-hide functionality** - Automatically hides when not needed and shows on scroll/hover
15
+ - πŸ“± **Responsive design** - Adapts to container size changes with ResizeObserver
16
+ - 🎯 **Interactive** - Support for click-to-scroll and drag-to-scroll functionality
17
+ - πŸ”§ **TypeScript support** - Full TypeScript support with proper type definitions
18
+ - πŸͺΆ **Lightweight** - No external dependencies except React
19
+ - β™Ώ **Accessible** - Maintains native scroll behavior while providing visual enhancements
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install @ehfuse/overlay-scrollbar
25
+ ```
26
+
27
+ or
28
+
29
+ ```bash
30
+ yarn add @ehfuse/overlay-scrollbar
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ For detailed setup instructions, see the [Getting Started Guide](https://github.com/ehfuse/overlay-scrollbar/blob/main/docs/getting-started-en.md).
36
+
37
+ ```tsx
38
+ import React from "react";
39
+ import { OverlayScrollbar } from "@ehfuse/overlay-scrollbar";
40
+
41
+ function App() {
42
+ return (
43
+ <div style={{ height: "400px" }}>
44
+ <OverlayScrollbar>
45
+ <div style={{ height: "1000px" }}>
46
+ {/* Your scrollable content here */}
47
+ </div>
48
+ </OverlayScrollbar>
49
+ </div>
50
+ );
51
+ }
52
+ ```
53
+
54
+ ## Usage
55
+
56
+ ### Basic Usage
57
+
58
+ ```tsx
59
+ import React from "react";
60
+ import { OverlayScrollbar } from "@ehfuse/overlay-scrollbar";
61
+
62
+ function App() {
63
+ return (
64
+ <div style={{ height: "400px" }}>
65
+ <OverlayScrollbar>
66
+ <div style={{ height: "1000px" }}>
67
+ {/* Your scrollable content here */}
68
+ <p>Long content that requires scrolling...</p>
69
+ </div>
70
+ </OverlayScrollbar>
71
+ </div>
72
+ );
73
+ }
74
+ ```
75
+
76
+ ### With Ref Access
77
+
78
+ ```tsx
79
+ import React, { useRef } from "react";
80
+ import {
81
+ OverlayScrollbar,
82
+ OverlayScrollbarRef,
83
+ } from "@ehfuse/overlay-scrollbar";
84
+
85
+ function App() {
86
+ const scrollbarRef = useRef<OverlayScrollbarRef>(null);
87
+
88
+ const scrollToTop = () => {
89
+ scrollbarRef.current?.scrollTo({ top: 0, behavior: "smooth" });
90
+ };
91
+
92
+ const getScrollInfo = () => {
93
+ if (scrollbarRef.current) {
94
+ console.log("Scroll Top:", scrollbarRef.current.scrollTop);
95
+ console.log("Scroll Height:", scrollbarRef.current.scrollHeight);
96
+ console.log("Client Height:", scrollbarRef.current.clientHeight);
97
+ }
98
+ };
99
+
100
+ return (
101
+ <div style={{ height: "400px" }}>
102
+ <button onClick={scrollToTop}>Scroll to Top</button>
103
+ <button onClick={getScrollInfo}>Get Scroll Info</button>
104
+
105
+ <OverlayScrollbar ref={scrollbarRef}>
106
+ <div style={{ height: "1000px" }}>
107
+ {/* Your scrollable content here */}
108
+ </div>
109
+ </OverlayScrollbar>
110
+ </div>
111
+ );
112
+ }
113
+ ```
114
+
115
+ ### With Custom Styling
116
+
117
+ ```tsx
118
+ import React from "react";
119
+ import { OverlayScrollbar } from "@ehfuse/overlay-scrollbar";
120
+
121
+ function App() {
122
+ return (
123
+ <OverlayScrollbar
124
+ className="my-scrollbar"
125
+ style={{
126
+ height: "400px",
127
+ border: "1px solid #ccc",
128
+ borderRadius: "8px",
129
+ }}
130
+ onScroll={(event) => {
131
+ console.log("Scrolled!", event);
132
+ }}
133
+ >
134
+ <div style={{ height: "1000px", padding: "20px" }}>
135
+ {/* Your content */}
136
+ </div>
137
+ </OverlayScrollbar>
138
+ );
139
+ }
140
+ ```
141
+
142
+ ## API Reference
143
+
144
+ ### Props
145
+
146
+ | Prop | Type | Default | Description |
147
+ | ----------- | ------------------------ | ------- | ------------------------------------------ |
148
+ | `children` | `ReactNode` | - | The content to be scrolled |
149
+ | `className` | `string` | - | Additional CSS class for the container |
150
+ | `style` | `React.CSSProperties` | - | Additional inline styles for the container |
151
+ | `onScroll` | `(event: Event) => void` | - | Callback fired when scrolling occurs |
152
+
153
+ ### Ref Methods
154
+
155
+ The component exposes several methods through ref:
156
+
157
+ | Method | Type | Description |
158
+ | -------------------- | ------------------------------------ | ---------------------------------------- |
159
+ | `getScrollContainer` | `() => HTMLDivElement \| null` | Returns the scrollable container element |
160
+ | `scrollTo` | `(options: ScrollToOptions) => void` | Scrolls to a specific position |
161
+ | `scrollTop` | `number` | Gets the current scroll top position |
162
+ | `scrollHeight` | `number` | Gets the total scrollable height |
163
+ | `clientHeight` | `number` | Gets the visible height of the container |
164
+
165
+ ### ScrollToOptions
166
+
167
+ ```typescript
168
+ interface ScrollToOptions {
169
+ top?: number;
170
+ left?: number;
171
+ behavior?: "auto" | "smooth";
172
+ }
173
+ ```
174
+
175
+ ## Behavior
176
+
177
+ - **Auto-hide**: The scrollbar automatically hides after 0.7 seconds of inactivity during wheel scroll or regular scrolling
178
+ - **Hover reveal**: Hovering over the right edge (20px wide area) shows the scrollbar with track background
179
+ - **Interactive scrolling**:
180
+ - Click on the track to jump to that position
181
+ - Drag the thumb for precise scrolling
182
+ - Mouse wheel scrolling works normally
183
+ - **Responsive**: Automatically adapts to content and container size changes
184
+ - **Smooth animations**: All show/hide transitions are smoothly animated
185
+
186
+ ## Styling
187
+
188
+ The component uses CSS-in-JS for styling and automatically hides native scrollbars. The custom scrollbar has:
189
+
190
+ - **Track**: Semi-transparent background that appears on hover/interaction
191
+ - **Thumb**: The draggable scrollbar handle with hover effects
192
+ - **Positioning**: 8px wide, positioned 2px from the right edge
193
+ - **Colors**: Configurable through CSS custom properties (future enhancement)
194
+
195
+ ## Browser Support
196
+
197
+ - Chrome/Edge: Full support
198
+ - Firefox: Full support
199
+ - Safari: Full support
200
+ - Mobile browsers: Touch scrolling supported, overlay scrollbar hidden on mobile
201
+
202
+ ## Performance
203
+
204
+ - Uses `ResizeObserver` for efficient size change detection
205
+ - Debounced scroll events to prevent excessive re-renders
206
+ - Passive event listeners where possible
207
+ - Minimal DOM manipulation and optimized for 60fps animations
208
+
209
+ ## License
210
+
211
+ MIT Β© [KIM YOUNG JIN](mailto:ehfuse@gmail.com)
212
+
213
+ ## Contributing
214
+
215
+ 1. Fork the repository
216
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
217
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
218
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
219
+ 5. Open a Pull Request
220
+
221
+ ## Issues
222
+
223
+ If you find any bugs or have feature requests, please create an issue on [GitHub](https://github.com/ehfuse/overlay-scrollbar/issues).
@@ -0,0 +1,43 @@
1
+ /**
2
+ * OverlayScrollbar.tsx
3
+ *
4
+ * A React component that provides a custom overlay scrollbar with smooth animations and auto-hide functionality
5
+ *
6
+ * @license MIT
7
+ * @copyright 2025 KIM YOUNG JIN (ehfuse@gmail.com)
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+ import React, { ReactNode } from "react";
28
+ interface OverlayScrollbarProps {
29
+ className?: string;
30
+ style?: React.CSSProperties;
31
+ children: ReactNode;
32
+ onScroll?: (event: Event) => void;
33
+ }
34
+ export interface OverlayScrollbarRef {
35
+ getScrollContainer: () => HTMLDivElement | null;
36
+ scrollTo: (options: ScrollToOptions) => void;
37
+ scrollTop: number;
38
+ scrollHeight: number;
39
+ clientHeight: number;
40
+ }
41
+ export declare const OverlayScrollbar: React.ForwardRefExoticComponent<OverlayScrollbarProps & React.RefAttributes<OverlayScrollbarRef>>;
42
+ export default OverlayScrollbar;
43
+ //# sourceMappingURL=OverlayScrollbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverlayScrollbar.d.ts","sourceRoot":"","sources":["../OverlayScrollbar.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,EAA4C,SAAS,EAAmC,MAAM,OAAO,CAAC;AAEpH,UAAU,qBAAqB;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACrC;AAGD,MAAM,WAAW,mBAAmB;IAChC,kBAAkB,EAAE,MAAM,cAAc,GAAG,IAAI,CAAC;IAChD,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,gBAAgB,mGAue5B,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * OverlayScrollbar.tsx
3
+ *
4
+ * A React component that provides a custom overlay scrollbar with smooth animations and auto-hide functionality
5
+ *
6
+ * @license MIT
7
+ * @copyright 2025 KIM YOUNG JIN (ehfuse@gmail.com)
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+ import React, { ReactNode } from "react";
28
+ interface OverlayScrollbarProps {
29
+ className?: string;
30
+ style?: React.CSSProperties;
31
+ children: ReactNode;
32
+ onScroll?: (event: Event) => void;
33
+ }
34
+ export interface OverlayScrollbarRef {
35
+ getScrollContainer: () => HTMLDivElement | null;
36
+ scrollTo: (options: ScrollToOptions) => void;
37
+ scrollTop: number;
38
+ scrollHeight: number;
39
+ clientHeight: number;
40
+ }
41
+ export declare const OverlayScrollbar: React.ForwardRefExoticComponent<OverlayScrollbarProps & React.RefAttributes<OverlayScrollbarRef>>;
42
+ export default OverlayScrollbar;
43
+ //# sourceMappingURL=OverlayScrollbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverlayScrollbar.d.ts","sourceRoot":"","sources":["../../core/OverlayScrollbar.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,EAKV,SAAS,EAGZ,MAAM,OAAO,CAAC;AAEf,UAAU,qBAAqB;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACrC;AAGD,MAAM,WAAW,mBAAmB;IAChC,kBAAkB,EAAE,MAAM,cAAc,GAAG,IAAI,CAAC;IAChD,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,gBAAgB,mGAogB3B,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ /**
4
+ * OverlayScrollbar.tsx
5
+ *
6
+ * A React component that provides a custom overlay scrollbar with smooth animations and auto-hide functionality
7
+ *
8
+ * @license MIT
9
+ * @copyright 2025 KIM YOUNG JIN (ehfuse@gmail.com)
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in all
19
+ * copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ * SOFTWARE.
28
+ */
29
+
30
+ interface OverlayScrollbarProps {
31
+ className?: string;
32
+ style?: React.CSSProperties;
33
+ children: ReactNode;
34
+ onScroll?: (event: Event) => void;
35
+ }
36
+ interface OverlayScrollbarRef {
37
+ getScrollContainer: () => HTMLDivElement | null;
38
+ scrollTo: (options: ScrollToOptions) => void;
39
+ scrollTop: number;
40
+ scrollHeight: number;
41
+ clientHeight: number;
42
+ }
43
+ declare const OverlayScrollbar: React.ForwardRefExoticComponent<OverlayScrollbarProps & React.RefAttributes<OverlayScrollbarRef>>;
44
+
45
+ export { OverlayScrollbar, OverlayScrollbar as default };
46
+ export type { OverlayScrollbarRef };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,IAAI,OAAO,EAC3B,gBAAgB,GACnB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}