@ehfuse/overlay-scrollbar 1.2.6 → 1.3.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/README.md +55 -202
- package/dist/index.d.ts +28 -12
- package/dist/index.esm.js +679 -104
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +678 -103
- package/dist/index.js.map +1 -1
- package/dist/src/OverlayScrollbar.d.ts +28 -12
- package/dist/src/OverlayScrollbar.d.ts.map +1 -1
- package/dist/src/utils/dragScrollUtils.d.ts +40 -0
- package/dist/src/utils/dragScrollUtils.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,299 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useRef, useState, useImperativeHandle, useCallback, useEffect
|
|
2
|
+
import { forwardRef, useRef, useState, useMemo, useImperativeHandle, useCallback, useEffect } from 'react';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* MIT License
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 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
|
+
// 드래그 스크롤을 제외할 클래스들 (자신 또는 부모 요소에서 확인)
|
|
28
|
+
const DEFAULT_EXCLUDE_CLASSES = [
|
|
29
|
+
// 기본 입력 요소들
|
|
30
|
+
"editor",
|
|
31
|
+
"textarea",
|
|
32
|
+
"input",
|
|
33
|
+
"select",
|
|
34
|
+
"textfield",
|
|
35
|
+
"form-control",
|
|
36
|
+
"contenteditable",
|
|
37
|
+
// Material-UI 컴포넌트들
|
|
38
|
+
"MuiInputBase-input",
|
|
39
|
+
"MuiSelect-select",
|
|
40
|
+
"MuiOutlinedInput-input",
|
|
41
|
+
"MuiFilledInput-input",
|
|
42
|
+
"MuiInput-input",
|
|
43
|
+
"MuiFormControl-root",
|
|
44
|
+
"MuiTextField-root",
|
|
45
|
+
"MuiSelect-root",
|
|
46
|
+
"MuiOutlinedInput-root",
|
|
47
|
+
"MuiFilledInput-root",
|
|
48
|
+
"MuiInput-root",
|
|
49
|
+
"MuiAutocomplete-input",
|
|
50
|
+
"MuiDatePicker-input",
|
|
51
|
+
"MuiSlider-thumb",
|
|
52
|
+
"MuiSlider-rail",
|
|
53
|
+
"MuiSlider-track",
|
|
54
|
+
"MuiSlider-mark",
|
|
55
|
+
"MuiSlider-markLabel",
|
|
56
|
+
"MuiSlider-root",
|
|
57
|
+
"MuiSlider-colorPrimary",
|
|
58
|
+
"MuiSlider-sizeMedium",
|
|
59
|
+
"MuiIconButton-root",
|
|
60
|
+
"MuiButton-root",
|
|
61
|
+
"MuiButtonBase-root",
|
|
62
|
+
"MuiTouchRipple-root",
|
|
63
|
+
"MuiCheckbox-root",
|
|
64
|
+
"MuiRadio-root",
|
|
65
|
+
"MuiSwitch-root",
|
|
66
|
+
"PrivateSwitchBase-root",
|
|
67
|
+
// Ant Design 컴포넌트들
|
|
68
|
+
"ant-input",
|
|
69
|
+
"ant-input-affix-wrapper",
|
|
70
|
+
"ant-input-group-addon",
|
|
71
|
+
"ant-input-number",
|
|
72
|
+
"ant-input-number-handler",
|
|
73
|
+
"ant-select",
|
|
74
|
+
"ant-select-selector",
|
|
75
|
+
"ant-select-selection-search",
|
|
76
|
+
"ant-select-dropdown",
|
|
77
|
+
"ant-cascader",
|
|
78
|
+
"ant-cascader-input",
|
|
79
|
+
"ant-picker",
|
|
80
|
+
"ant-picker-input",
|
|
81
|
+
"ant-time-picker",
|
|
82
|
+
"ant-calendar-picker",
|
|
83
|
+
"ant-slider",
|
|
84
|
+
"ant-slider-track",
|
|
85
|
+
"ant-slider-handle",
|
|
86
|
+
"ant-switch",
|
|
87
|
+
"ant-checkbox",
|
|
88
|
+
"ant-checkbox-wrapper",
|
|
89
|
+
"ant-radio",
|
|
90
|
+
"ant-radio-wrapper",
|
|
91
|
+
"ant-rate",
|
|
92
|
+
"ant-upload",
|
|
93
|
+
"ant-upload-drag",
|
|
94
|
+
"ant-form-item",
|
|
95
|
+
"ant-form-item-control",
|
|
96
|
+
"ant-btn",
|
|
97
|
+
"ant-dropdown",
|
|
98
|
+
"ant-dropdown-trigger",
|
|
99
|
+
"ant-menu",
|
|
100
|
+
"ant-menu-item",
|
|
101
|
+
"ant-tooltip",
|
|
102
|
+
"ant-popover",
|
|
103
|
+
"ant-modal",
|
|
104
|
+
"ant-drawer",
|
|
105
|
+
"ant-tree-select",
|
|
106
|
+
"ant-auto-complete",
|
|
107
|
+
"ant-mentions",
|
|
108
|
+
"ant-transfer",
|
|
109
|
+
// Shadcn/ui 컴포넌트들
|
|
110
|
+
"ui-input",
|
|
111
|
+
"ui-textarea",
|
|
112
|
+
"ui-select",
|
|
113
|
+
"ui-select-trigger",
|
|
114
|
+
"ui-select-content",
|
|
115
|
+
"ui-select-item",
|
|
116
|
+
"ui-button",
|
|
117
|
+
"ui-checkbox",
|
|
118
|
+
"ui-radio-group",
|
|
119
|
+
"ui-switch",
|
|
120
|
+
"ui-slider",
|
|
121
|
+
"ui-range-slider",
|
|
122
|
+
"ui-calendar",
|
|
123
|
+
"ui-date-picker",
|
|
124
|
+
"ui-combobox",
|
|
125
|
+
"ui-command",
|
|
126
|
+
"ui-command-input",
|
|
127
|
+
"ui-popover",
|
|
128
|
+
"ui-dialog",
|
|
129
|
+
"ui-sheet",
|
|
130
|
+
"ui-dropdown-menu",
|
|
131
|
+
"ui-context-menu",
|
|
132
|
+
"ui-menubar",
|
|
133
|
+
"ui-navigation-menu",
|
|
134
|
+
"ui-form",
|
|
135
|
+
"ui-form-control",
|
|
136
|
+
"ui-form-item",
|
|
137
|
+
"ui-form-field",
|
|
138
|
+
"ui-label",
|
|
139
|
+
// Radix UI 기본 클래스들 (Shadcn 기반)
|
|
140
|
+
"radix-ui",
|
|
141
|
+
"radix-select",
|
|
142
|
+
"radix-dropdown",
|
|
143
|
+
"radix-dialog",
|
|
144
|
+
"radix-popover",
|
|
145
|
+
"radix-accordion",
|
|
146
|
+
"radix-tabs",
|
|
147
|
+
"radix-slider",
|
|
148
|
+
"radix-switch",
|
|
149
|
+
"radix-checkbox",
|
|
150
|
+
"radix-radio",
|
|
151
|
+
// Quill Editor
|
|
152
|
+
"ql-editor",
|
|
153
|
+
"ql-container",
|
|
154
|
+
"ql-toolbar",
|
|
155
|
+
"ql-picker",
|
|
156
|
+
"ql-picker-label",
|
|
157
|
+
"ql-picker-options",
|
|
158
|
+
"ql-formats",
|
|
159
|
+
"ql-snow",
|
|
160
|
+
"ql-bubble",
|
|
161
|
+
"quill",
|
|
162
|
+
"quilleditor",
|
|
163
|
+
// Monaco Editor
|
|
164
|
+
"monaco-editor",
|
|
165
|
+
"monaco-editor-background",
|
|
166
|
+
"view-lines",
|
|
167
|
+
"decorationsOverviewRuler",
|
|
168
|
+
"monaco-scrollable-element",
|
|
169
|
+
// CodeMirror
|
|
170
|
+
"CodeMirror",
|
|
171
|
+
"CodeMirror-code",
|
|
172
|
+
"CodeMirror-lines",
|
|
173
|
+
"CodeMirror-scroll",
|
|
174
|
+
"CodeMirror-sizer",
|
|
175
|
+
"cm-editor",
|
|
176
|
+
"cm-focused",
|
|
177
|
+
"cm-content",
|
|
178
|
+
// TinyMCE
|
|
179
|
+
"tox-editor-container",
|
|
180
|
+
"tox-editor-header",
|
|
181
|
+
"tox-edit-area",
|
|
182
|
+
"tox-tinymce",
|
|
183
|
+
"mce-content-body",
|
|
184
|
+
// CKEditor
|
|
185
|
+
"ck-editor",
|
|
186
|
+
"ck-content",
|
|
187
|
+
"ck-toolbar",
|
|
188
|
+
"ck-editor__editable",
|
|
189
|
+
"ck-widget",
|
|
190
|
+
// Slate.js
|
|
191
|
+
"slate-editor",
|
|
192
|
+
"slate-content",
|
|
193
|
+
// Draft.js
|
|
194
|
+
"DraftEditor-root",
|
|
195
|
+
"DraftEditor-editorContainer",
|
|
196
|
+
"public-DraftEditor-content",
|
|
197
|
+
// EhfuseEditor
|
|
198
|
+
"ehfuse-editor",
|
|
199
|
+
"ehfuse-editor-wrapper",
|
|
200
|
+
"ehfuse-editor-content",
|
|
201
|
+
"ehfuse-toolbar",
|
|
202
|
+
"ehfuse-toolbar-group",
|
|
203
|
+
"ehfuse-cursor",
|
|
204
|
+
// 기타 에디터들
|
|
205
|
+
"text-editor",
|
|
206
|
+
"rich-text-editor",
|
|
207
|
+
"wysiwyg",
|
|
208
|
+
"ace_editor",
|
|
209
|
+
"ace_content",
|
|
210
|
+
];
|
|
211
|
+
/**
|
|
212
|
+
* 드래그 스크롤이 허용되지 않는 요소들인지 확인
|
|
213
|
+
*/
|
|
214
|
+
/**
|
|
215
|
+
* 드래그 스크롤이 허용되지 않는 요소들인지 확인
|
|
216
|
+
*/
|
|
217
|
+
const isTextInputElement = (element, config) => {
|
|
218
|
+
const tagName = element.tagName.toLowerCase();
|
|
219
|
+
const inputTypes = [
|
|
220
|
+
"text",
|
|
221
|
+
"password",
|
|
222
|
+
"email",
|
|
223
|
+
"number",
|
|
224
|
+
"search",
|
|
225
|
+
"tel",
|
|
226
|
+
"url",
|
|
227
|
+
"checkbox",
|
|
228
|
+
"radio",
|
|
229
|
+
];
|
|
230
|
+
// input 태그이면서 텍스트 입력 타입이나 체크박스/라디오인 경우
|
|
231
|
+
if (tagName === "input") {
|
|
232
|
+
const type = element.type;
|
|
233
|
+
return inputTypes.includes(type);
|
|
234
|
+
}
|
|
235
|
+
// textarea, select, 편집 가능한 요소들
|
|
236
|
+
if (["textarea", "select", "button"].includes(tagName)) {
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
// SVG 요소들 (아이콘들)
|
|
240
|
+
if ([
|
|
241
|
+
"svg",
|
|
242
|
+
"path",
|
|
243
|
+
"circle",
|
|
244
|
+
"rect",
|
|
245
|
+
"line",
|
|
246
|
+
"polygon",
|
|
247
|
+
"polyline",
|
|
248
|
+
].includes(tagName)) {
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
// contenteditable 속성이 있는 요소
|
|
252
|
+
if (element.getAttribute("contenteditable") === "true") {
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
// 추가 셀렉터 체크
|
|
256
|
+
if (config === null || config === void 0 ? void 0 : config.excludeSelectors) {
|
|
257
|
+
for (const selector of config.excludeSelectors) {
|
|
258
|
+
if (element.matches(selector)) {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return checkElementAndParents(element, config);
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* 자신 또는 부모 요소들을 확인하여 드래그 스크롤을 제외할 요소인지 판단
|
|
267
|
+
*/
|
|
268
|
+
const checkElementAndParents = (element, config) => {
|
|
269
|
+
// 모든 제외 클래스들 합치기 (기본 클래스 + 사용자 추가 클래스)
|
|
270
|
+
const allExcludeClasses = [
|
|
271
|
+
...DEFAULT_EXCLUDE_CLASSES,
|
|
272
|
+
...((config === null || config === void 0 ? void 0 : config.excludeClasses) || []),
|
|
273
|
+
];
|
|
274
|
+
let currentElement = element;
|
|
275
|
+
let depth = 0;
|
|
276
|
+
const maxDepth = 5; // 최대 5단계까지 부모 요소 확인
|
|
277
|
+
while (currentElement && depth <= maxDepth) {
|
|
278
|
+
// 현재 요소가 제외 클래스를 가지고 있는지 확인
|
|
279
|
+
if (allExcludeClasses.some((cls) => currentElement.classList.contains(cls))) {
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
// 다이얼로그 루트에 도달하면 중단
|
|
283
|
+
if (currentElement.classList.contains("MuiDialogContent-root")) {
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
currentElement = currentElement.parentElement;
|
|
287
|
+
depth++;
|
|
288
|
+
}
|
|
289
|
+
return false;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const OverlayScrollbar = forwardRef(({ className = "", style = {}, children, onScroll, scrollContainer: externalScrollContainer,
|
|
293
|
+
// 그룹화된 설정 객체들
|
|
294
|
+
thumb = {}, track = {}, arrows = {}, dragScroll = {},
|
|
295
|
+
// 기타 설정들
|
|
296
|
+
showScrollbar = true, hideDelay = 1500, hideDelayOnWheel = 700, }, ref) => {
|
|
6
297
|
const containerRef = useRef(null);
|
|
7
298
|
const contentRef = useRef(null);
|
|
8
299
|
const scrollbarRef = useRef(null);
|
|
@@ -13,6 +304,14 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
13
304
|
const [dragStart, setDragStart] = useState({ y: 0, scrollTop: 0 });
|
|
14
305
|
const [thumbHeight, setThumbHeight] = useState(0);
|
|
15
306
|
const [thumbTop, setThumbTop] = useState(0);
|
|
307
|
+
// 드래그 스크롤 상태
|
|
308
|
+
const [isDragScrolling, setIsDragScrolling] = useState(false);
|
|
309
|
+
const [dragScrollStart, setDragScrollStart] = useState({
|
|
310
|
+
x: 0,
|
|
311
|
+
y: 0,
|
|
312
|
+
scrollTop: 0,
|
|
313
|
+
scrollLeft: 0,
|
|
314
|
+
});
|
|
16
315
|
const [activeArrow, setActiveArrow] = useState(null);
|
|
17
316
|
const [hoveredArrow, setHoveredArrow] = useState(null);
|
|
18
317
|
// 초기 마운트 시 hover 방지용
|
|
@@ -22,6 +321,48 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
22
321
|
const [isWheelScrolling, setIsWheelScrolling] = useState(false);
|
|
23
322
|
// 숨김 타이머
|
|
24
323
|
const hideTimeoutRef = useRef(null);
|
|
324
|
+
// 그룹화된 설정 객체들에 기본값 설정
|
|
325
|
+
const finalThumbConfig = useMemo(() => {
|
|
326
|
+
var _a, _b, _c, _d, _e, _f;
|
|
327
|
+
return ({
|
|
328
|
+
width: (_a = thumb.width) !== null && _a !== void 0 ? _a : 8,
|
|
329
|
+
minHeight: (_b = thumb.minHeight) !== null && _b !== void 0 ? _b : 50,
|
|
330
|
+
radius: (_c = thumb.radius) !== null && _c !== void 0 ? _c : ((_d = thumb.width) !== null && _d !== void 0 ? _d : 8) / 2,
|
|
331
|
+
color: (_e = thumb.color) !== null && _e !== void 0 ? _e : "rgba(128, 128, 128, 0.6)",
|
|
332
|
+
activeColor: (_f = thumb.activeColor) !== null && _f !== void 0 ? _f : "rgba(128, 128, 128, 0.9)",
|
|
333
|
+
});
|
|
334
|
+
}, [thumb]);
|
|
335
|
+
const finalTrackConfig = useMemo(() => {
|
|
336
|
+
var _a, _b, _c;
|
|
337
|
+
return ({
|
|
338
|
+
width: (_a = track.width) !== null && _a !== void 0 ? _a : 16,
|
|
339
|
+
color: (_b = track.color) !== null && _b !== void 0 ? _b : "rgba(128, 128, 128, 0.1)",
|
|
340
|
+
visible: (_c = track.visible) !== null && _c !== void 0 ? _c : true,
|
|
341
|
+
});
|
|
342
|
+
}, [track]);
|
|
343
|
+
const finalArrowsConfig = useMemo(() => {
|
|
344
|
+
var _a, _b, _c, _d;
|
|
345
|
+
return ({
|
|
346
|
+
visible: (_a = arrows.visible) !== null && _a !== void 0 ? _a : false,
|
|
347
|
+
step: (_b = arrows.step) !== null && _b !== void 0 ? _b : 50,
|
|
348
|
+
color: (_c = arrows.color) !== null && _c !== void 0 ? _c : "rgba(128, 128, 128, 0.8)",
|
|
349
|
+
activeColor: (_d = arrows.activeColor) !== null && _d !== void 0 ? _d : "rgba(64, 64, 64, 1.0)",
|
|
350
|
+
});
|
|
351
|
+
}, [arrows]);
|
|
352
|
+
const finalDragScrollConfig = useMemo(() => {
|
|
353
|
+
var _a, _b, _c;
|
|
354
|
+
return ({
|
|
355
|
+
enabled: (_a = dragScroll.enabled) !== null && _a !== void 0 ? _a : true,
|
|
356
|
+
excludeClasses: (_b = dragScroll.excludeClasses) !== null && _b !== void 0 ? _b : [],
|
|
357
|
+
excludeSelectors: (_c = dragScroll.excludeSelectors) !== null && _c !== void 0 ? _c : [],
|
|
358
|
+
});
|
|
359
|
+
}, [dragScroll]);
|
|
360
|
+
// 호환성을 위한 변수들 (자주 사용되는 변수들만 유지)
|
|
361
|
+
const finalThumbWidth = finalThumbConfig.width;
|
|
362
|
+
const finalTrackWidth = finalTrackConfig.width;
|
|
363
|
+
const thumbMinHeight = finalThumbConfig.minHeight;
|
|
364
|
+
const showArrows = finalArrowsConfig.visible;
|
|
365
|
+
const arrowStep = finalArrowsConfig.step;
|
|
25
366
|
// ref를 통해 외부에서 스크롤 컨테이너에 접근할 수 있도록 함
|
|
26
367
|
useImperativeHandle(ref, () => ({
|
|
27
368
|
getScrollContainer: () => containerRef.current,
|
|
@@ -43,13 +384,61 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
43
384
|
return ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0;
|
|
44
385
|
},
|
|
45
386
|
}), []);
|
|
387
|
+
// 실제 스크롤 가능한 요소 찾기
|
|
388
|
+
const findScrollableElement = useCallback(() => {
|
|
389
|
+
// externalScrollContainer가 있으면 우선 사용
|
|
390
|
+
if (externalScrollContainer) {
|
|
391
|
+
console.log("OverlayScrollbar: checking external container", {
|
|
392
|
+
scrollHeight: externalScrollContainer.scrollHeight,
|
|
393
|
+
clientHeight: externalScrollContainer.clientHeight,
|
|
394
|
+
});
|
|
395
|
+
// virtuoso의 내부 스크롤러를 찾기
|
|
396
|
+
const virtuosoScroller = externalScrollContainer.querySelector('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller');
|
|
397
|
+
if (virtuosoScroller) {
|
|
398
|
+
const element = virtuosoScroller;
|
|
399
|
+
if (element.scrollHeight > element.clientHeight + 2) {
|
|
400
|
+
console.log("OverlayScrollbar: found virtuoso scroller", {
|
|
401
|
+
scrollHeight: element.scrollHeight,
|
|
402
|
+
clientHeight: element.clientHeight,
|
|
403
|
+
element,
|
|
404
|
+
});
|
|
405
|
+
return element;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
// externalScrollContainer 자체가 스크롤 가능한지 확인
|
|
409
|
+
if (externalScrollContainer.scrollHeight >
|
|
410
|
+
externalScrollContainer.clientHeight + 2) {
|
|
411
|
+
return externalScrollContainer;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (!containerRef.current) {
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
// 내부 컨테이너의 스크롤 가능 여부 확인
|
|
418
|
+
if (contentRef.current &&
|
|
419
|
+
contentRef.current.scrollHeight >
|
|
420
|
+
containerRef.current.clientHeight + 2) {
|
|
421
|
+
return containerRef.current;
|
|
422
|
+
}
|
|
423
|
+
// children 요소에서 스크롤 가능한 요소 찾기
|
|
424
|
+
const childScrollableElements = containerRef.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');
|
|
425
|
+
for (const child of childScrollableElements) {
|
|
426
|
+
const element = child;
|
|
427
|
+
if (element.scrollHeight > element.clientHeight + 2) {
|
|
428
|
+
console.log("OverlayScrollbar: found scrollable child element", {
|
|
429
|
+
scrollHeight: element.scrollHeight,
|
|
430
|
+
clientHeight: element.clientHeight,
|
|
431
|
+
element,
|
|
432
|
+
});
|
|
433
|
+
return element;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return null;
|
|
437
|
+
}, [externalScrollContainer]);
|
|
46
438
|
// 스크롤 가능 여부 체크
|
|
47
439
|
const isScrollable = useCallback(() => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return (contentRef.current.scrollHeight >
|
|
51
|
-
containerRef.current.clientHeight + 2);
|
|
52
|
-
}, []);
|
|
440
|
+
return findScrollableElement() !== null;
|
|
441
|
+
}, [findScrollableElement]);
|
|
53
442
|
// 타이머 정리
|
|
54
443
|
const clearHideTimer = useCallback(() => {
|
|
55
444
|
if (hideTimeoutRef.current) {
|
|
@@ -67,23 +456,26 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
67
456
|
}, [clearHideTimer, isDragging]);
|
|
68
457
|
// 스크롤바 위치 및 크기 업데이트
|
|
69
458
|
const updateScrollbar = useCallback(() => {
|
|
70
|
-
if (!
|
|
71
|
-
!contentRef.current ||
|
|
72
|
-
!scrollbarRef.current)
|
|
459
|
+
if (!scrollbarRef.current)
|
|
73
460
|
return;
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const contentHeight = content.scrollHeight;
|
|
78
|
-
const scrollTop = container.scrollTop;
|
|
79
|
-
// 스크롤 불가능하면 숨김
|
|
80
|
-
if (contentHeight <= containerHeight + 2) {
|
|
461
|
+
const scrollableElement = findScrollableElement();
|
|
462
|
+
if (!scrollableElement) {
|
|
463
|
+
// 스크롤 불가능하면 숨김
|
|
81
464
|
setScrollbarVisible(false);
|
|
82
465
|
clearHideTimer();
|
|
83
466
|
return;
|
|
84
467
|
}
|
|
468
|
+
const containerHeight = scrollableElement.clientHeight;
|
|
469
|
+
const contentHeight = scrollableElement.scrollHeight;
|
|
470
|
+
const scrollTop = scrollableElement.scrollTop;
|
|
471
|
+
console.log("OverlayScrollbar: updating scrollbar", {
|
|
472
|
+
containerHeight,
|
|
473
|
+
contentHeight,
|
|
474
|
+
scrollTop,
|
|
475
|
+
element: scrollableElement,
|
|
476
|
+
});
|
|
85
477
|
// 화살표와 간격 공간 계산 (화살표 + 위아래여백 4px + 화살표간격 4px씩, 화살표 없어도 위아래 4px씩 여백)
|
|
86
|
-
const arrowSpace = showArrows ?
|
|
478
|
+
const arrowSpace = showArrows ? finalThumbWidth * 2 + 16 : 8;
|
|
87
479
|
// 썸 높이 계산 (사용자 설정 최소 높이 사용, 화살표 공간 제외)
|
|
88
480
|
const availableHeight = containerHeight - arrowSpace;
|
|
89
481
|
const scrollRatio = containerHeight / contentHeight;
|
|
@@ -96,37 +488,58 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
96
488
|
: 0;
|
|
97
489
|
setThumbHeight(calculatedThumbHeight);
|
|
98
490
|
setThumbTop(calculatedThumbTop);
|
|
99
|
-
}, [
|
|
491
|
+
}, [
|
|
492
|
+
findScrollableElement,
|
|
493
|
+
clearHideTimer,
|
|
494
|
+
showArrows,
|
|
495
|
+
finalThumbWidth,
|
|
496
|
+
thumbMinHeight,
|
|
497
|
+
]);
|
|
100
498
|
// 썸 드래그 시작
|
|
101
499
|
const handleThumbMouseDown = useCallback((event) => {
|
|
500
|
+
var _a;
|
|
102
501
|
event.preventDefault();
|
|
103
502
|
event.stopPropagation();
|
|
104
|
-
|
|
503
|
+
const actualScrollContainer = findScrollableElement();
|
|
504
|
+
if (!actualScrollContainer) {
|
|
505
|
+
console.log("Thumb drag - no scrollable element found");
|
|
105
506
|
return;
|
|
507
|
+
}
|
|
106
508
|
setIsDragging(true);
|
|
107
509
|
setDragStart({
|
|
108
510
|
y: event.clientY,
|
|
109
|
-
scrollTop:
|
|
511
|
+
scrollTop: actualScrollContainer.scrollTop,
|
|
110
512
|
});
|
|
111
513
|
clearHideTimer();
|
|
112
514
|
setScrollbarVisible(true);
|
|
113
|
-
|
|
515
|
+
// 포커스 유지 (키보드 입력이 계속 작동하도록)
|
|
516
|
+
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
517
|
+
}, [findScrollableElement, clearHideTimer]);
|
|
114
518
|
// 썸 드래그 중
|
|
115
519
|
const handleMouseMove = useCallback((event) => {
|
|
116
|
-
if (!isDragging
|
|
520
|
+
if (!isDragging)
|
|
117
521
|
return;
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
522
|
+
const actualScrollContainer = findScrollableElement();
|
|
523
|
+
if (!actualScrollContainer) {
|
|
524
|
+
console.log("Mouse move - no scrollable element found");
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const containerHeight = actualScrollContainer.clientHeight;
|
|
528
|
+
const contentHeight = actualScrollContainer.scrollHeight;
|
|
122
529
|
const scrollableHeight = contentHeight - containerHeight;
|
|
123
530
|
const deltaY = event.clientY - dragStart.y;
|
|
124
531
|
const thumbScrollableHeight = containerHeight - thumbHeight;
|
|
125
532
|
const scrollDelta = (deltaY / thumbScrollableHeight) * scrollableHeight;
|
|
126
533
|
const newScrollTop = Math.max(0, Math.min(scrollableHeight, dragStart.scrollTop + scrollDelta));
|
|
127
|
-
|
|
534
|
+
actualScrollContainer.scrollTop = newScrollTop;
|
|
128
535
|
updateScrollbar();
|
|
129
|
-
}, [
|
|
536
|
+
}, [
|
|
537
|
+
isDragging,
|
|
538
|
+
dragStart,
|
|
539
|
+
thumbHeight,
|
|
540
|
+
updateScrollbar,
|
|
541
|
+
findScrollableElement,
|
|
542
|
+
]);
|
|
130
543
|
// 썸 드래그 종료
|
|
131
544
|
const handleMouseUp = useCallback(() => {
|
|
132
545
|
setIsDragging(false);
|
|
@@ -136,26 +549,43 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
136
549
|
}, [isScrollable, setHideTimer, hideDelay]);
|
|
137
550
|
// 트랙 클릭으로 스크롤 점프
|
|
138
551
|
const handleTrackClick = useCallback((event) => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
552
|
+
var _a;
|
|
553
|
+
console.log("handleTrackClick called", event);
|
|
554
|
+
if (!scrollbarRef.current) {
|
|
555
|
+
console.log("Track click - scrollbarRef not available");
|
|
142
556
|
return;
|
|
557
|
+
}
|
|
143
558
|
const scrollbar = scrollbarRef.current;
|
|
144
559
|
const rect = scrollbar.getBoundingClientRect();
|
|
145
560
|
const clickY = event.clientY - rect.top;
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
561
|
+
const actualScrollContainer = findScrollableElement();
|
|
562
|
+
if (!actualScrollContainer) {
|
|
563
|
+
console.log("Track click - no scrollable element found");
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
console.log("Track click - using scrollable element", actualScrollContainer);
|
|
567
|
+
const containerHeight = actualScrollContainer.clientHeight;
|
|
568
|
+
const contentHeight = actualScrollContainer.scrollHeight;
|
|
150
569
|
const scrollRatio = clickY / containerHeight;
|
|
151
570
|
const newScrollTop = scrollRatio * (contentHeight - containerHeight);
|
|
152
|
-
|
|
571
|
+
console.log("Track click scroll calculation", {
|
|
572
|
+
clickY,
|
|
573
|
+
containerHeight,
|
|
574
|
+
contentHeight,
|
|
575
|
+
scrollRatio,
|
|
576
|
+
newScrollTop,
|
|
577
|
+
actualScrollContainer,
|
|
578
|
+
});
|
|
579
|
+
actualScrollContainer.scrollTop = Math.max(0, Math.min(contentHeight - containerHeight, newScrollTop));
|
|
153
580
|
updateScrollbar();
|
|
154
581
|
setScrollbarVisible(true);
|
|
155
582
|
setHideTimer(hideDelay);
|
|
156
|
-
|
|
583
|
+
// 포커스 유지 (키보드 입력이 계속 작동하도록)
|
|
584
|
+
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
585
|
+
}, [updateScrollbar, setHideTimer, hideDelay, findScrollableElement]);
|
|
157
586
|
// 위쪽 화살표 클릭 핸들러
|
|
158
587
|
const handleUpArrowClick = useCallback((event) => {
|
|
588
|
+
var _a;
|
|
159
589
|
event.preventDefault();
|
|
160
590
|
event.stopPropagation();
|
|
161
591
|
if (!containerRef.current)
|
|
@@ -165,9 +595,12 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
165
595
|
updateScrollbar();
|
|
166
596
|
setScrollbarVisible(true);
|
|
167
597
|
setHideTimer(hideDelay);
|
|
598
|
+
// 포커스 유지 (키보드 입력이 계속 작동하도록)
|
|
599
|
+
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
168
600
|
}, [updateScrollbar, setHideTimer, arrowStep, hideDelay]);
|
|
169
601
|
// 아래쪽 화살표 클릭 핸들러
|
|
170
602
|
const handleDownArrowClick = useCallback((event) => {
|
|
603
|
+
var _a;
|
|
171
604
|
event.preventDefault();
|
|
172
605
|
event.stopPropagation();
|
|
173
606
|
if (!containerRef.current || !contentRef.current)
|
|
@@ -180,12 +613,75 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
180
613
|
updateScrollbar();
|
|
181
614
|
setScrollbarVisible(true);
|
|
182
615
|
setHideTimer(hideDelay);
|
|
616
|
+
// 포커스 유지 (키보드 입력이 계속 작동하도록)
|
|
617
|
+
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
183
618
|
}, [updateScrollbar, setHideTimer, arrowStep, hideDelay]);
|
|
184
|
-
// 스크롤
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (!
|
|
619
|
+
// 드래그 스크롤 시작
|
|
620
|
+
const handleDragScrollStart = useCallback((event) => {
|
|
621
|
+
// 드래그 스크롤이 비활성화된 경우
|
|
622
|
+
if (!finalDragScrollConfig.enabled)
|
|
623
|
+
return;
|
|
624
|
+
// 텍스트 입력 요소나 제외 대상이면 드래그 스크롤 하지 않음
|
|
625
|
+
const target = event.target;
|
|
626
|
+
if (isTextInputElement(target, finalDragScrollConfig)) {
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
// 오른쪽 클릭이나 휠 클릭은 제외
|
|
630
|
+
if (event.button !== 0)
|
|
631
|
+
return;
|
|
632
|
+
const scrollableElement = findScrollableElement();
|
|
633
|
+
if (!scrollableElement)
|
|
188
634
|
return;
|
|
635
|
+
// 스크롤 가능한 영역이 아니면 제외
|
|
636
|
+
if (scrollableElement.scrollHeight <=
|
|
637
|
+
scrollableElement.clientHeight)
|
|
638
|
+
return;
|
|
639
|
+
event.preventDefault();
|
|
640
|
+
setIsDragScrolling(true);
|
|
641
|
+
setDragScrollStart({
|
|
642
|
+
x: event.clientX,
|
|
643
|
+
y: event.clientY,
|
|
644
|
+
scrollTop: scrollableElement.scrollTop,
|
|
645
|
+
scrollLeft: scrollableElement.scrollLeft || 0,
|
|
646
|
+
});
|
|
647
|
+
// 스크롤바 표시
|
|
648
|
+
clearHideTimer();
|
|
649
|
+
setScrollbarVisible(true);
|
|
650
|
+
}, [
|
|
651
|
+
finalDragScrollConfig,
|
|
652
|
+
isTextInputElement,
|
|
653
|
+
findScrollableElement,
|
|
654
|
+
clearHideTimer,
|
|
655
|
+
]);
|
|
656
|
+
// 드래그 스크롤 중
|
|
657
|
+
const handleDragScrollMove = useCallback((event) => {
|
|
658
|
+
if (!isDragScrolling)
|
|
659
|
+
return;
|
|
660
|
+
const scrollableElement = findScrollableElement();
|
|
661
|
+
if (!scrollableElement)
|
|
662
|
+
return;
|
|
663
|
+
dragScrollStart.x - event.clientX;
|
|
664
|
+
const deltaY = dragScrollStart.y - event.clientY;
|
|
665
|
+
// 세로 스크롤만 처리 (가로 스크롤은 필요시 나중에 추가)
|
|
666
|
+
const newScrollTop = Math.max(0, Math.min(scrollableElement.scrollHeight -
|
|
667
|
+
scrollableElement.clientHeight, dragScrollStart.scrollTop + deltaY));
|
|
668
|
+
scrollableElement.scrollTop = newScrollTop;
|
|
669
|
+
updateScrollbar();
|
|
670
|
+
}, [
|
|
671
|
+
isDragScrolling,
|
|
672
|
+
dragScrollStart,
|
|
673
|
+
findScrollableElement,
|
|
674
|
+
updateScrollbar,
|
|
675
|
+
]);
|
|
676
|
+
// 드래그 스크롤 종료
|
|
677
|
+
const handleDragScrollEnd = useCallback(() => {
|
|
678
|
+
setIsDragScrolling(false);
|
|
679
|
+
if (isScrollable()) {
|
|
680
|
+
setHideTimer(hideDelay);
|
|
681
|
+
}
|
|
682
|
+
}, [isScrollable, setHideTimer, hideDelay]);
|
|
683
|
+
// 스크롤 이벤트 리스너 (externalScrollContainer 우선 사용)
|
|
684
|
+
useEffect(() => {
|
|
189
685
|
const handleScroll = (event) => {
|
|
190
686
|
updateScrollbar();
|
|
191
687
|
// 스크롤 중에는 스크롤바 표시
|
|
@@ -212,20 +708,44 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
212
708
|
clearHideTimer();
|
|
213
709
|
setScrollbarVisible(true);
|
|
214
710
|
};
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
711
|
+
const elementsToWatch = [];
|
|
712
|
+
// 실제 스크롤 가능한 요소 찾기
|
|
713
|
+
const scrollableElement = findScrollableElement();
|
|
714
|
+
if (scrollableElement) {
|
|
715
|
+
elementsToWatch.push(scrollableElement);
|
|
716
|
+
console.log("OverlayScrollbar: watching scrollable element for events", scrollableElement);
|
|
717
|
+
}
|
|
718
|
+
// fallback: 내부 컨테이너와 children 요소도 감지
|
|
719
|
+
const container = containerRef.current;
|
|
720
|
+
if (container && !scrollableElement) {
|
|
721
|
+
elementsToWatch.push(container);
|
|
722
|
+
// children 요소들의 스크롤도 감지
|
|
723
|
+
const childScrollableElements = container.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');
|
|
724
|
+
childScrollableElements.forEach((child) => {
|
|
725
|
+
elementsToWatch.push(child);
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
// 모든 요소에 이벤트 리스너 등록
|
|
729
|
+
elementsToWatch.forEach((element) => {
|
|
730
|
+
element.addEventListener("scroll", handleScroll, {
|
|
731
|
+
passive: true,
|
|
732
|
+
});
|
|
733
|
+
element.addEventListener("wheel", handleWheel, {
|
|
734
|
+
passive: true,
|
|
735
|
+
});
|
|
220
736
|
});
|
|
221
737
|
return () => {
|
|
222
|
-
|
|
223
|
-
|
|
738
|
+
// 모든 이벤트 리스너 제거
|
|
739
|
+
elementsToWatch.forEach((element) => {
|
|
740
|
+
element.removeEventListener("scroll", handleScroll);
|
|
741
|
+
element.removeEventListener("wheel", handleWheel);
|
|
742
|
+
});
|
|
224
743
|
if (wheelTimeoutRef.current) {
|
|
225
744
|
clearTimeout(wheelTimeoutRef.current);
|
|
226
745
|
}
|
|
227
746
|
};
|
|
228
747
|
}, [
|
|
748
|
+
findScrollableElement,
|
|
229
749
|
updateScrollbar,
|
|
230
750
|
onScroll,
|
|
231
751
|
clearHideTimer,
|
|
@@ -234,6 +754,17 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
234
754
|
hideDelayOnWheel,
|
|
235
755
|
isWheelScrolling,
|
|
236
756
|
]);
|
|
757
|
+
// 드래그 스크롤 전역 마우스 이벤트 리스너
|
|
758
|
+
useEffect(() => {
|
|
759
|
+
if (isDragScrolling) {
|
|
760
|
+
document.addEventListener("mousemove", handleDragScrollMove);
|
|
761
|
+
document.addEventListener("mouseup", handleDragScrollEnd);
|
|
762
|
+
return () => {
|
|
763
|
+
document.removeEventListener("mousemove", handleDragScrollMove);
|
|
764
|
+
document.removeEventListener("mouseup", handleDragScrollEnd);
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
}, [isDragScrolling, handleDragScrollMove, handleDragScrollEnd]);
|
|
237
768
|
// 전역 마우스 이벤트 리스너
|
|
238
769
|
useEffect(() => {
|
|
239
770
|
if (isDragging) {
|
|
@@ -247,44 +778,63 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
247
778
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
248
779
|
// 초기 스크롤바 업데이트
|
|
249
780
|
useEffect(() => {
|
|
781
|
+
// 즉시 업데이트
|
|
250
782
|
updateScrollbar();
|
|
783
|
+
// 약간의 지연 후에도 업데이트 (DOM이 완전히 렌더링된 후)
|
|
784
|
+
const timer = setTimeout(() => {
|
|
785
|
+
updateScrollbar();
|
|
786
|
+
}, 100);
|
|
787
|
+
return () => clearTimeout(timer);
|
|
251
788
|
}, [updateScrollbar]);
|
|
789
|
+
// externalScrollContainer가 변경될 때 스크롤바 업데이트
|
|
790
|
+
useEffect(() => {
|
|
791
|
+
if (externalScrollContainer) {
|
|
792
|
+
// externalScrollContainer가 설정된 후 스크롤바 업데이트
|
|
793
|
+
const timer = setTimeout(() => {
|
|
794
|
+
updateScrollbar();
|
|
795
|
+
}, 50);
|
|
796
|
+
return () => clearTimeout(timer);
|
|
797
|
+
}
|
|
798
|
+
}, [externalScrollContainer, updateScrollbar]);
|
|
252
799
|
// 컴포넌트 초기화 완료 표시 (hover 이벤트 활성화용)
|
|
253
800
|
useEffect(() => {
|
|
254
801
|
const timer = setTimeout(() => {
|
|
255
802
|
setIsInitialized(true);
|
|
256
|
-
|
|
803
|
+
console.log("OverlayScrollbar initialized", {
|
|
804
|
+
containerRef: !!containerRef.current,
|
|
805
|
+
contentRef: !!contentRef.current,
|
|
806
|
+
isScrollable: isScrollable(),
|
|
807
|
+
});
|
|
808
|
+
// 초기화 후 스크롤바 업데이트 (썸 높이 정확하게 계산)
|
|
809
|
+
updateScrollbar();
|
|
810
|
+
}, 100);
|
|
257
811
|
return () => clearTimeout(timer);
|
|
258
|
-
}, []);
|
|
812
|
+
}, [isScrollable]);
|
|
259
813
|
// Resize observer로 크기 변경 감지
|
|
260
814
|
useEffect(() => {
|
|
261
|
-
if (!containerRef.current || !contentRef.current)
|
|
262
|
-
return;
|
|
263
815
|
const resizeObserver = new ResizeObserver(() => {
|
|
264
816
|
updateScrollbar();
|
|
265
817
|
});
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
// 계산된 값들을 메모이제이션하여 안정화
|
|
271
|
-
const { finalThumbWidth, finalTrackWidth } = useMemo(() => {
|
|
272
|
-
const computedThumbWidth = thumbWidth !== undefined ? thumbWidth : scrollbarWidth;
|
|
273
|
-
let computedTrackWidth = trackWidth !== undefined ? trackWidth : scrollbarWidth * 2;
|
|
274
|
-
// thumbWidth가 trackWidth보다 크거나 같으면 trackWidth를 thumbWidth와 같게 설정
|
|
275
|
-
if (computedThumbWidth >= computedTrackWidth) {
|
|
276
|
-
computedTrackWidth = computedThumbWidth;
|
|
818
|
+
const elementsToObserve = [];
|
|
819
|
+
// externalScrollContainer가 있으면 우선 관찰
|
|
820
|
+
if (externalScrollContainer) {
|
|
821
|
+
elementsToObserve.push(externalScrollContainer);
|
|
277
822
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
823
|
+
// 내부 컨테이너들도 관찰
|
|
824
|
+
if (containerRef.current) {
|
|
825
|
+
elementsToObserve.push(containerRef.current);
|
|
826
|
+
}
|
|
827
|
+
if (contentRef.current) {
|
|
828
|
+
elementsToObserve.push(contentRef.current);
|
|
829
|
+
}
|
|
830
|
+
// 모든 요소들 관찰 시작
|
|
831
|
+
elementsToObserve.forEach((element) => {
|
|
832
|
+
resizeObserver.observe(element);
|
|
833
|
+
});
|
|
834
|
+
return () => resizeObserver.disconnect();
|
|
835
|
+
}, [updateScrollbar, externalScrollContainer]);
|
|
836
|
+
// trackWidth가 thumbWidth보다 작으면 thumbWidth와 같게 설정
|
|
837
|
+
const adjustedTrackWidth = Math.max(finalTrackWidth, finalThumbWidth);
|
|
288
838
|
// 웹킷 스크롤바 숨기기용 CSS 동적 주입
|
|
289
839
|
useEffect(() => {
|
|
290
840
|
const styleId = "overlay-scrollbar-webkit-hide";
|
|
@@ -307,6 +857,14 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
307
857
|
.overlay-scrollbar-container::-webkit-scrollbar-thumb {
|
|
308
858
|
display: none !important;
|
|
309
859
|
}
|
|
860
|
+
.overlay-scrollbar-container:focus {
|
|
861
|
+
outline: 2px solid rgba(0, 123, 255, 0.3);
|
|
862
|
+
outline-offset: -2px;
|
|
863
|
+
}
|
|
864
|
+
.overlay-scrollbar-container:focus-visible {
|
|
865
|
+
outline: 2px solid rgba(0, 123, 255, 0.5);
|
|
866
|
+
outline-offset: -2px;
|
|
867
|
+
}
|
|
310
868
|
`;
|
|
311
869
|
document.head.appendChild(style);
|
|
312
870
|
return () => {
|
|
@@ -316,60 +874,77 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
316
874
|
}
|
|
317
875
|
};
|
|
318
876
|
}, []);
|
|
319
|
-
return (jsxs("div", { className: `overlay-scrollbar-wrapper ${className}`, style: Object.assign({ display: "flex", flexDirection: "column", position: "relative", minHeight: 0, height: "100%", flex: "1 1 0%" }, style), children: [jsx("div", { ref: containerRef, className: "overlay-scrollbar-container", style: {
|
|
877
|
+
return (jsxs("div", { className: `overlay-scrollbar-wrapper ${className}`, style: Object.assign({ display: "flex", flexDirection: "column", position: "relative", minHeight: 0, height: "100%", flex: "1 1 0%" }, style), children: [jsx("div", { ref: containerRef, className: "overlay-scrollbar-container", tabIndex: -1, onMouseDown: handleDragScrollStart, style: {
|
|
320
878
|
width: "100%", // 명시적 너비 설정
|
|
321
|
-
height: "100%", //
|
|
879
|
+
height: "100%", // 부모의 전체 높이 사용
|
|
880
|
+
flex: "1 1 auto", // flex item으로 설정하여 높이를 자동으로 계산
|
|
322
881
|
minHeight: 0, // 최소 높이 보장
|
|
323
882
|
overflow: "auto", // 네이티브 스크롤 기능 유지
|
|
324
883
|
// 브라우저 기본 스크롤바만 숨기기
|
|
325
884
|
scrollbarWidth: "none", // Firefox
|
|
326
885
|
msOverflowStyle: "none", // IE/Edge
|
|
886
|
+
// 키보드 포커스 스타일 (접근성)
|
|
887
|
+
outline: "none", // 기본 아웃라인 제거
|
|
888
|
+
userSelect: isDragScrolling ? "none" : "auto", // 드래그 중 텍스트 선택 방지
|
|
327
889
|
}, children: jsx("div", { ref: contentRef, className: "overlay-scrollbar-content", style: {
|
|
328
|
-
|
|
890
|
+
height: "100%", // min-height 대신 height 사용
|
|
891
|
+
minHeight: 0, // flex shrink 허용
|
|
892
|
+
display: "flex", // flex 컨테이너로 설정
|
|
893
|
+
flexDirection: "column", // 세로 방향 정렬
|
|
329
894
|
}, children: children }) }), showScrollbar && (jsxs("div", { ref: scrollbarRef, className: "overlay-scrollbar-track", onMouseEnter: () => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
895
|
+
console.log("Track hover enter", {
|
|
896
|
+
isScrollable: isScrollable(),
|
|
897
|
+
scrollbarVisible,
|
|
898
|
+
});
|
|
899
|
+
clearHideTimer();
|
|
900
|
+
setScrollbarVisible(true);
|
|
334
901
|
}, onMouseLeave: () => {
|
|
335
|
-
|
|
902
|
+
console.log("Track hover leave", { isDragging });
|
|
903
|
+
if (!isDragging) {
|
|
336
904
|
setHideTimer(hideDelay);
|
|
337
905
|
}
|
|
338
906
|
}, style: {
|
|
339
907
|
position: "absolute",
|
|
340
908
|
top: 0,
|
|
341
|
-
right: 0,
|
|
342
|
-
width: `${
|
|
909
|
+
right: 0,
|
|
910
|
+
width: `${adjustedTrackWidth}px`,
|
|
343
911
|
height: "100%",
|
|
344
912
|
opacity: scrollbarVisible ? 1 : 0,
|
|
345
913
|
transition: "opacity 0.2s ease-in-out",
|
|
346
914
|
cursor: "pointer",
|
|
347
915
|
zIndex: 1000,
|
|
348
|
-
pointerEvents: "auto",
|
|
349
|
-
}, children: [jsx("div", { className: "overlay-scrollbar-track-background", onClick:
|
|
916
|
+
pointerEvents: "auto",
|
|
917
|
+
}, children: [finalTrackConfig.visible && (jsx("div", { className: "overlay-scrollbar-track-background", onClick: (e) => {
|
|
918
|
+
console.log("Track background clicked", e);
|
|
919
|
+
e.preventDefault();
|
|
920
|
+
e.stopPropagation();
|
|
921
|
+
handleTrackClick(e);
|
|
922
|
+
}, style: {
|
|
350
923
|
position: "absolute",
|
|
351
924
|
top: showArrows
|
|
352
|
-
? `${
|
|
925
|
+
? `${finalThumbConfig.width + 8}px`
|
|
353
926
|
: "4px",
|
|
354
|
-
right: `${(
|
|
355
|
-
|
|
927
|
+
right: `${(adjustedTrackWidth -
|
|
928
|
+
finalThumbConfig.width) /
|
|
929
|
+
2}px`, // 트랙 가운데 정렬
|
|
930
|
+
width: `${finalThumbConfig.width}px`,
|
|
356
931
|
height: showArrows
|
|
357
|
-
? `calc(100% - ${
|
|
932
|
+
? `calc(100% - ${finalThumbConfig.width * 2 + 16}px)`
|
|
358
933
|
: "calc(100% - 8px)",
|
|
359
|
-
backgroundColor:
|
|
360
|
-
borderRadius: `${
|
|
934
|
+
backgroundColor: finalTrackConfig.color,
|
|
935
|
+
borderRadius: `${finalThumbConfig.radius}px`,
|
|
361
936
|
cursor: "pointer",
|
|
362
|
-
} }), jsx("div", { ref: thumbRef, className: "overlay-scrollbar-thumb", onMouseDown: handleThumbMouseDown, style: {
|
|
937
|
+
} })), jsx("div", { ref: thumbRef, className: "overlay-scrollbar-thumb", onMouseDown: handleThumbMouseDown, style: {
|
|
363
938
|
position: "absolute",
|
|
364
939
|
top: `${(showArrows ? finalThumbWidth + 8 : 4) +
|
|
365
940
|
thumbTop}px`,
|
|
366
|
-
right: `${(
|
|
941
|
+
right: `${(adjustedTrackWidth - finalThumbWidth) / 2}px`, // 트랙 가운데 정렬
|
|
367
942
|
width: `${finalThumbWidth}px`,
|
|
368
943
|
height: `${Math.max(thumbHeight, thumbMinHeight)}px`,
|
|
369
944
|
backgroundColor: isDragging
|
|
370
|
-
?
|
|
371
|
-
:
|
|
372
|
-
borderRadius: `${
|
|
945
|
+
? finalThumbConfig.activeColor
|
|
946
|
+
: finalThumbConfig.color,
|
|
947
|
+
borderRadius: `${finalThumbConfig.radius}px`,
|
|
373
948
|
cursor: "pointer",
|
|
374
949
|
transition: isDragging
|
|
375
950
|
? "none"
|
|
@@ -377,7 +952,7 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
377
952
|
} })] })), showScrollbar && showArrows && (jsx("div", { className: "overlay-scrollbar-up-arrow", onClick: handleUpArrowClick, onMouseEnter: () => setHoveredArrow("up"), onMouseLeave: () => setHoveredArrow(null), style: {
|
|
378
953
|
position: "absolute",
|
|
379
954
|
top: "4px",
|
|
380
|
-
right: `${(
|
|
955
|
+
right: `${(adjustedTrackWidth - finalThumbWidth) / 2}px`, // 트랙 가운데 정렬
|
|
381
956
|
width: `${finalThumbWidth}px`,
|
|
382
957
|
height: `${finalThumbWidth}px`,
|
|
383
958
|
cursor: "pointer",
|
|
@@ -386,8 +961,8 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
386
961
|
justifyContent: "center",
|
|
387
962
|
fontSize: `${Math.max(finalThumbWidth * 0.75, 8)}px`,
|
|
388
963
|
color: hoveredArrow === "up"
|
|
389
|
-
?
|
|
390
|
-
:
|
|
964
|
+
? finalArrowsConfig.activeColor
|
|
965
|
+
: finalArrowsConfig.color,
|
|
391
966
|
userSelect: "none",
|
|
392
967
|
zIndex: 1001,
|
|
393
968
|
opacity: scrollbarVisible ? 1 : 0,
|
|
@@ -395,7 +970,7 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
395
970
|
}, children: "\u25B2" })), showScrollbar && showArrows && (jsx("div", { className: "overlay-scrollbar-down-arrow", onClick: handleDownArrowClick, onMouseEnter: () => setHoveredArrow("down"), onMouseLeave: () => setHoveredArrow(null), style: {
|
|
396
971
|
position: "absolute",
|
|
397
972
|
bottom: "4px",
|
|
398
|
-
right: `${(
|
|
973
|
+
right: `${(adjustedTrackWidth - finalThumbWidth) / 2}px`, // 트랙 가운데 정렬
|
|
399
974
|
width: `${finalThumbWidth}px`,
|
|
400
975
|
height: `${finalThumbWidth}px`,
|
|
401
976
|
cursor: "pointer",
|
|
@@ -404,8 +979,8 @@ thumbRadius, showScrollbar = true, showArrows = false, arrowStep = 50, trackWidt
|
|
|
404
979
|
justifyContent: "center",
|
|
405
980
|
fontSize: `${Math.max(finalThumbWidth * 0.75, 8)}px`,
|
|
406
981
|
color: hoveredArrow === "down"
|
|
407
|
-
?
|
|
408
|
-
:
|
|
982
|
+
? finalArrowsConfig.activeColor
|
|
983
|
+
: finalArrowsConfig.color,
|
|
409
984
|
userSelect: "none",
|
|
410
985
|
zIndex: 1001,
|
|
411
986
|
opacity: scrollbarVisible ? 1 : 0,
|