funda-ui 1.0.407 → 1.0.408
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/RangeSlider/index.js +2 -2
- package/Scrollbar/index.js +19 -28
- package/lib/cjs/RangeSlider/index.js +2 -2
- package/lib/cjs/Scrollbar/index.js +19 -28
- package/lib/esm/RangeSlider/index.tsx +2 -3
- package/lib/esm/Scrollbar/index.tsx +42 -55
- package/package.json +1 -1
package/RangeSlider/index.js
CHANGED
|
@@ -620,7 +620,7 @@ var RangeSlider = function RangeSlider(props) {
|
|
|
620
620
|
type: "text",
|
|
621
621
|
id: idRes + '-min',
|
|
622
622
|
name: minName,
|
|
623
|
-
value: minValue.toString() // Convert to a string to ensure that 0 can also be filled
|
|
623
|
+
value: typeof minValue !== 'undefined' ? minValue.toString() : min // Convert to a string to ensure that 0 can also be filled
|
|
624
624
|
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((funda_input__WEBPACK_IMPORTED_MODULE_1___default()), {
|
|
625
625
|
ref: valMaxRef,
|
|
626
626
|
wrapperClassName: wrapperClassName || wrapperClassName === '' ? wrapperClassName : "mb-3 position-relative",
|
|
@@ -629,7 +629,7 @@ var RangeSlider = function RangeSlider(props) {
|
|
|
629
629
|
type: "text",
|
|
630
630
|
id: idRes + '-max',
|
|
631
631
|
name: maxName,
|
|
632
|
-
value: maxValue.toString() // Convert to a string to ensure that 0 can also be filled
|
|
632
|
+
value: typeof maxValue !== 'undefined' ? maxValue.toString() : max // Convert to a string to ensure that 0 can also be filled
|
|
633
633
|
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
634
634
|
className: "range-slider__control-wrapper ".concat(disabled ? 'disabled' : '')
|
|
635
635
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
package/Scrollbar/index.js
CHANGED
|
@@ -343,21 +343,14 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
343
343
|
var thumb = scrollThumbRef.current;
|
|
344
344
|
thumb.style.top = "".concat(newTop, "px");
|
|
345
345
|
}, []);
|
|
346
|
-
var
|
|
346
|
+
var handleThumbMouseDown = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
347
347
|
e.preventDefault();
|
|
348
348
|
e.stopPropagation();
|
|
349
349
|
setScrollStartPosition(e.clientY);
|
|
350
350
|
if (contentRef.current) setInitialScrollTop(contentRef.current.scrollTop);
|
|
351
351
|
setIsDragging(true);
|
|
352
352
|
}, []);
|
|
353
|
-
var
|
|
354
|
-
e.preventDefault();
|
|
355
|
-
e.stopPropagation();
|
|
356
|
-
if (isDragging) {
|
|
357
|
-
setIsDragging(false);
|
|
358
|
-
}
|
|
359
|
-
}, [isDragging]);
|
|
360
|
-
var handleThumbMousemove = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
353
|
+
var handleThumbMouseMove = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
361
354
|
e.preventDefault();
|
|
362
355
|
e.stopPropagation();
|
|
363
356
|
if (isDragging && contentRef.current && scrollStartPosition) {
|
|
@@ -369,6 +362,13 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
369
362
|
contentRef.current.scrollTop = newScrollTop;
|
|
370
363
|
}
|
|
371
364
|
}, [isDragging, scrollStartPosition, thumbHeight]);
|
|
365
|
+
var handleThumbMouseUp = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
366
|
+
e.preventDefault();
|
|
367
|
+
e.stopPropagation();
|
|
368
|
+
if (isDragging) {
|
|
369
|
+
setIsDragging(false);
|
|
370
|
+
}
|
|
371
|
+
}, [isDragging]);
|
|
372
372
|
|
|
373
373
|
// Horizontal --> functions
|
|
374
374
|
//========================================
|
|
@@ -440,21 +440,21 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
440
440
|
var thumb = scrollThumbHorizontalRef.current;
|
|
441
441
|
thumb.style.left = "".concat(newLeft, "px");
|
|
442
442
|
}, []);
|
|
443
|
-
var
|
|
443
|
+
var handleHorizontalThumbMouseDown = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
444
444
|
e.preventDefault();
|
|
445
445
|
e.stopPropagation();
|
|
446
446
|
setScrollHorizontalStartPosition(e.clientX);
|
|
447
447
|
if (contentRef.current) setInitialScrollLeft(contentRef.current.scrollLeft);
|
|
448
448
|
setIsHorizontalDragging(true);
|
|
449
449
|
}, []);
|
|
450
|
-
var
|
|
450
|
+
var handleHorizontalThumbMouseUp = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
451
451
|
e.preventDefault();
|
|
452
452
|
e.stopPropagation();
|
|
453
453
|
if (isHorizontalDragging) {
|
|
454
454
|
setIsHorizontalDragging(false);
|
|
455
455
|
}
|
|
456
456
|
}, [isHorizontalDragging]);
|
|
457
|
-
var
|
|
457
|
+
var handleHorizontalThumbMouseMove = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
458
458
|
e.preventDefault();
|
|
459
459
|
e.stopPropagation();
|
|
460
460
|
if (isHorizontalDragging && contentRef.current && scrollHorizontalStartPosition) {
|
|
@@ -510,13 +510,6 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
510
510
|
|
|
511
511
|
// Listen for mouse events to handle scrolling by dragging the thumb
|
|
512
512
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
513
|
-
document.addEventListener('mousemove', handleThumbMousemove);
|
|
514
|
-
document.addEventListener('mouseup', handleThumbMouseup);
|
|
515
|
-
document.addEventListener('mouseleave', handleThumbMouseup);
|
|
516
|
-
document.addEventListener('mousemove', handleHorizontalThumbMousemove);
|
|
517
|
-
document.addEventListener('mouseup', handleHorizontalThumbMouseup);
|
|
518
|
-
document.addEventListener('mouseleave', handleHorizontalThumbMouseup);
|
|
519
|
-
|
|
520
513
|
// Add function to the element that should be used as the scrollable area.
|
|
521
514
|
if (contentRef.current) {
|
|
522
515
|
contentRef.current.removeEventListener('wheel', contentAreaScrollUpdate);
|
|
@@ -524,17 +517,11 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
524
517
|
contentAreaScrollUpdate();
|
|
525
518
|
}
|
|
526
519
|
return function () {
|
|
527
|
-
document.removeEventListener('mousemove', handleThumbMousemove);
|
|
528
|
-
document.removeEventListener('mouseup', handleThumbMouseup);
|
|
529
|
-
document.removeEventListener('mouseleave', handleThumbMouseup);
|
|
530
|
-
document.removeEventListener('mousemove', handleHorizontalThumbMousemove);
|
|
531
|
-
document.removeEventListener('mouseup', handleHorizontalThumbMouseup);
|
|
532
|
-
document.removeEventListener('mouseleave', handleHorizontalThumbMouseup);
|
|
533
520
|
if (contentRef.current) {
|
|
534
521
|
contentRef.current.removeEventListener('wheel', contentAreaScrollUpdate);
|
|
535
522
|
}
|
|
536
523
|
};
|
|
537
|
-
}, [
|
|
524
|
+
}, [handleThumbMouseMove, handleThumbMouseUp, handleHorizontalThumbMouseMove, handleHorizontalThumbMouseUp]);
|
|
538
525
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
539
526
|
id: idRes,
|
|
540
527
|
ref: rootRef,
|
|
@@ -567,7 +554,9 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
567
554
|
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
568
555
|
className: "custom-scrollbars__thumb",
|
|
569
556
|
ref: scrollThumbRef,
|
|
570
|
-
onMouseDown:
|
|
557
|
+
onMouseDown: handleThumbMouseDown,
|
|
558
|
+
onMouseMove: handleThumbMouseMove,
|
|
559
|
+
onMouseUp: handleThumbMouseUp,
|
|
571
560
|
style: {
|
|
572
561
|
height: "".concat(thumbHeight, "px"),
|
|
573
562
|
cursor: isDragging ? 'grabbing' : 'grab'
|
|
@@ -604,7 +593,9 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
604
593
|
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
605
594
|
className: "custom-scrollbars__thumb",
|
|
606
595
|
ref: scrollThumbHorizontalRef,
|
|
607
|
-
onMouseDown:
|
|
596
|
+
onMouseDown: handleHorizontalThumbMouseDown,
|
|
597
|
+
onMouseMove: handleHorizontalThumbMouseMove,
|
|
598
|
+
onMouseUp: handleHorizontalThumbMouseUp,
|
|
608
599
|
style: {
|
|
609
600
|
width: "".concat(thumbWidth, "px"),
|
|
610
601
|
cursor: isHorizontalDragging ? 'grabbing' : 'grab'
|
|
@@ -620,7 +620,7 @@ var RangeSlider = function RangeSlider(props) {
|
|
|
620
620
|
type: "text",
|
|
621
621
|
id: idRes + '-min',
|
|
622
622
|
name: minName,
|
|
623
|
-
value: minValue.toString() // Convert to a string to ensure that 0 can also be filled
|
|
623
|
+
value: typeof minValue !== 'undefined' ? minValue.toString() : min // Convert to a string to ensure that 0 can also be filled
|
|
624
624
|
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((funda_input__WEBPACK_IMPORTED_MODULE_1___default()), {
|
|
625
625
|
ref: valMaxRef,
|
|
626
626
|
wrapperClassName: wrapperClassName || wrapperClassName === '' ? wrapperClassName : "mb-3 position-relative",
|
|
@@ -629,7 +629,7 @@ var RangeSlider = function RangeSlider(props) {
|
|
|
629
629
|
type: "text",
|
|
630
630
|
id: idRes + '-max',
|
|
631
631
|
name: maxName,
|
|
632
|
-
value: maxValue.toString() // Convert to a string to ensure that 0 can also be filled
|
|
632
|
+
value: typeof maxValue !== 'undefined' ? maxValue.toString() : max // Convert to a string to ensure that 0 can also be filled
|
|
633
633
|
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
634
634
|
className: "range-slider__control-wrapper ".concat(disabled ? 'disabled' : '')
|
|
635
635
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
@@ -343,21 +343,14 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
343
343
|
var thumb = scrollThumbRef.current;
|
|
344
344
|
thumb.style.top = "".concat(newTop, "px");
|
|
345
345
|
}, []);
|
|
346
|
-
var
|
|
346
|
+
var handleThumbMouseDown = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
347
347
|
e.preventDefault();
|
|
348
348
|
e.stopPropagation();
|
|
349
349
|
setScrollStartPosition(e.clientY);
|
|
350
350
|
if (contentRef.current) setInitialScrollTop(contentRef.current.scrollTop);
|
|
351
351
|
setIsDragging(true);
|
|
352
352
|
}, []);
|
|
353
|
-
var
|
|
354
|
-
e.preventDefault();
|
|
355
|
-
e.stopPropagation();
|
|
356
|
-
if (isDragging) {
|
|
357
|
-
setIsDragging(false);
|
|
358
|
-
}
|
|
359
|
-
}, [isDragging]);
|
|
360
|
-
var handleThumbMousemove = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
353
|
+
var handleThumbMouseMove = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
361
354
|
e.preventDefault();
|
|
362
355
|
e.stopPropagation();
|
|
363
356
|
if (isDragging && contentRef.current && scrollStartPosition) {
|
|
@@ -369,6 +362,13 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
369
362
|
contentRef.current.scrollTop = newScrollTop;
|
|
370
363
|
}
|
|
371
364
|
}, [isDragging, scrollStartPosition, thumbHeight]);
|
|
365
|
+
var handleThumbMouseUp = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
366
|
+
e.preventDefault();
|
|
367
|
+
e.stopPropagation();
|
|
368
|
+
if (isDragging) {
|
|
369
|
+
setIsDragging(false);
|
|
370
|
+
}
|
|
371
|
+
}, [isDragging]);
|
|
372
372
|
|
|
373
373
|
// Horizontal --> functions
|
|
374
374
|
//========================================
|
|
@@ -440,21 +440,21 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
440
440
|
var thumb = scrollThumbHorizontalRef.current;
|
|
441
441
|
thumb.style.left = "".concat(newLeft, "px");
|
|
442
442
|
}, []);
|
|
443
|
-
var
|
|
443
|
+
var handleHorizontalThumbMouseDown = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
444
444
|
e.preventDefault();
|
|
445
445
|
e.stopPropagation();
|
|
446
446
|
setScrollHorizontalStartPosition(e.clientX);
|
|
447
447
|
if (contentRef.current) setInitialScrollLeft(contentRef.current.scrollLeft);
|
|
448
448
|
setIsHorizontalDragging(true);
|
|
449
449
|
}, []);
|
|
450
|
-
var
|
|
450
|
+
var handleHorizontalThumbMouseUp = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
451
451
|
e.preventDefault();
|
|
452
452
|
e.stopPropagation();
|
|
453
453
|
if (isHorizontalDragging) {
|
|
454
454
|
setIsHorizontalDragging(false);
|
|
455
455
|
}
|
|
456
456
|
}, [isHorizontalDragging]);
|
|
457
|
-
var
|
|
457
|
+
var handleHorizontalThumbMouseMove = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
|
|
458
458
|
e.preventDefault();
|
|
459
459
|
e.stopPropagation();
|
|
460
460
|
if (isHorizontalDragging && contentRef.current && scrollHorizontalStartPosition) {
|
|
@@ -510,13 +510,6 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
510
510
|
|
|
511
511
|
// Listen for mouse events to handle scrolling by dragging the thumb
|
|
512
512
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
513
|
-
document.addEventListener('mousemove', handleThumbMousemove);
|
|
514
|
-
document.addEventListener('mouseup', handleThumbMouseup);
|
|
515
|
-
document.addEventListener('mouseleave', handleThumbMouseup);
|
|
516
|
-
document.addEventListener('mousemove', handleHorizontalThumbMousemove);
|
|
517
|
-
document.addEventListener('mouseup', handleHorizontalThumbMouseup);
|
|
518
|
-
document.addEventListener('mouseleave', handleHorizontalThumbMouseup);
|
|
519
|
-
|
|
520
513
|
// Add function to the element that should be used as the scrollable area.
|
|
521
514
|
if (contentRef.current) {
|
|
522
515
|
contentRef.current.removeEventListener('wheel', contentAreaScrollUpdate);
|
|
@@ -524,17 +517,11 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
524
517
|
contentAreaScrollUpdate();
|
|
525
518
|
}
|
|
526
519
|
return function () {
|
|
527
|
-
document.removeEventListener('mousemove', handleThumbMousemove);
|
|
528
|
-
document.removeEventListener('mouseup', handleThumbMouseup);
|
|
529
|
-
document.removeEventListener('mouseleave', handleThumbMouseup);
|
|
530
|
-
document.removeEventListener('mousemove', handleHorizontalThumbMousemove);
|
|
531
|
-
document.removeEventListener('mouseup', handleHorizontalThumbMouseup);
|
|
532
|
-
document.removeEventListener('mouseleave', handleHorizontalThumbMouseup);
|
|
533
520
|
if (contentRef.current) {
|
|
534
521
|
contentRef.current.removeEventListener('wheel', contentAreaScrollUpdate);
|
|
535
522
|
}
|
|
536
523
|
};
|
|
537
|
-
}, [
|
|
524
|
+
}, [handleThumbMouseMove, handleThumbMouseUp, handleHorizontalThumbMouseMove, handleHorizontalThumbMouseUp]);
|
|
538
525
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
539
526
|
id: idRes,
|
|
540
527
|
ref: rootRef,
|
|
@@ -567,7 +554,9 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
567
554
|
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
568
555
|
className: "custom-scrollbars__thumb",
|
|
569
556
|
ref: scrollThumbRef,
|
|
570
|
-
onMouseDown:
|
|
557
|
+
onMouseDown: handleThumbMouseDown,
|
|
558
|
+
onMouseMove: handleThumbMouseMove,
|
|
559
|
+
onMouseUp: handleThumbMouseUp,
|
|
571
560
|
style: {
|
|
572
561
|
height: "".concat(thumbHeight, "px"),
|
|
573
562
|
cursor: isDragging ? 'grabbing' : 'grab'
|
|
@@ -604,7 +593,9 @@ var Scrollbar = function Scrollbar(props) {
|
|
|
604
593
|
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
605
594
|
className: "custom-scrollbars__thumb",
|
|
606
595
|
ref: scrollThumbHorizontalRef,
|
|
607
|
-
onMouseDown:
|
|
596
|
+
onMouseDown: handleHorizontalThumbMouseDown,
|
|
597
|
+
onMouseMove: handleHorizontalThumbMouseMove,
|
|
598
|
+
onMouseUp: handleHorizontalThumbMouseUp,
|
|
608
599
|
style: {
|
|
609
600
|
width: "".concat(thumbWidth, "px"),
|
|
610
601
|
cursor: isHorizontalDragging ? 'grabbing' : 'grab'
|
|
@@ -2,7 +2,6 @@ import React, { useId, useEffect, useState, useRef } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import Input from 'funda-input';
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
type RangeSliderProps = {
|
|
7
6
|
wrapperClassName?: string;
|
|
8
7
|
controlClassName?: string;
|
|
@@ -131,7 +130,7 @@ const RangeSlider = (props: RangeSliderProps) => {
|
|
|
131
130
|
type="text"
|
|
132
131
|
id={idRes + '-min'}
|
|
133
132
|
name={minName}
|
|
134
|
-
value={minValue.toString()} // Convert to a string to ensure that 0 can also be filled
|
|
133
|
+
value={typeof minValue !== 'undefined' ? minValue.toString() : min} // Convert to a string to ensure that 0 can also be filled
|
|
135
134
|
/>
|
|
136
135
|
|
|
137
136
|
<Input
|
|
@@ -142,7 +141,7 @@ const RangeSlider = (props: RangeSliderProps) => {
|
|
|
142
141
|
type="text"
|
|
143
142
|
id={idRes + '-max'}
|
|
144
143
|
name={maxName}
|
|
145
|
-
value={maxValue.toString()} // Convert to a string to ensure that 0 can also be filled
|
|
144
|
+
value={typeof maxValue !== 'undefined' ? maxValue.toString() : max} // Convert to a string to ensure that 0 can also be filled
|
|
146
145
|
/>
|
|
147
146
|
|
|
148
147
|
|
|
@@ -175,7 +175,7 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
175
175
|
thumb.style.top = `${newTop}px`;
|
|
176
176
|
}, []);
|
|
177
177
|
|
|
178
|
-
const
|
|
178
|
+
const handleThumbMouseDown = useCallback((e: React.MouseEvent) => {
|
|
179
179
|
e.preventDefault();
|
|
180
180
|
e.stopPropagation();
|
|
181
181
|
setScrollStartPosition(e.clientY);
|
|
@@ -183,40 +183,37 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
183
183
|
setIsDragging(true);
|
|
184
184
|
}, []);
|
|
185
185
|
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
186
|
+
const handleThumbMouseMove = useCallback((e: React.MouseEvent) => {
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
e.stopPropagation();
|
|
189
|
+
if (isDragging && contentRef.current && scrollStartPosition) {
|
|
190
|
+
const {
|
|
191
|
+
scrollHeight: contentScrollHeight,
|
|
192
|
+
offsetHeight: contentOffsetHeight,
|
|
193
|
+
} = contentRef.current;
|
|
194
|
+
|
|
195
|
+
const deltaY =
|
|
196
|
+
(e.clientY - scrollStartPosition) *
|
|
197
|
+
(contentOffsetHeight / thumbHeight);
|
|
198
|
+
const newScrollTop = Math.min(
|
|
199
|
+
initialScrollTop + deltaY,
|
|
200
|
+
contentScrollHeight - contentOffsetHeight
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
contentRef.current.scrollTop = newScrollTop;
|
|
204
|
+
}
|
|
205
|
+
}, [isDragging, scrollStartPosition, thumbHeight]);
|
|
196
206
|
|
|
197
|
-
const handleThumbMousemove = useCallback(
|
|
198
|
-
(e: React.MouseEvent) => {
|
|
199
|
-
e.preventDefault();
|
|
200
|
-
e.stopPropagation();
|
|
201
|
-
if (isDragging && contentRef.current && scrollStartPosition) {
|
|
202
|
-
const {
|
|
203
|
-
scrollHeight: contentScrollHeight,
|
|
204
|
-
offsetHeight: contentOffsetHeight,
|
|
205
|
-
} = contentRef.current;
|
|
206
207
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
208
|
+
const handleThumbMouseUp = useCallback((e: React.MouseEvent) => {
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
e.stopPropagation();
|
|
211
|
+
if (isDragging) {
|
|
212
|
+
setIsDragging(false);
|
|
213
|
+
}
|
|
214
|
+
}, [isDragging]);
|
|
215
|
+
|
|
214
216
|
|
|
215
|
-
contentRef.current.scrollTop = newScrollTop;
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
[isDragging, scrollStartPosition, thumbHeight]
|
|
219
|
-
) as any;
|
|
220
217
|
|
|
221
218
|
|
|
222
219
|
// Horizontal --> functions
|
|
@@ -300,7 +297,7 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
300
297
|
thumb.style.left = `${newLeft}px`;
|
|
301
298
|
}, []);
|
|
302
299
|
|
|
303
|
-
const
|
|
300
|
+
const handleHorizontalThumbMouseDown = useCallback((e: React.MouseEvent) => {
|
|
304
301
|
e.preventDefault();
|
|
305
302
|
e.stopPropagation();
|
|
306
303
|
setScrollHorizontalStartPosition(e.clientX);
|
|
@@ -308,7 +305,7 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
308
305
|
setIsHorizontalDragging(true);
|
|
309
306
|
}, []);
|
|
310
307
|
|
|
311
|
-
const
|
|
308
|
+
const handleHorizontalThumbMouseUp = useCallback(
|
|
312
309
|
(e: React.MouseEvent) => {
|
|
313
310
|
e.preventDefault();
|
|
314
311
|
e.stopPropagation();
|
|
@@ -317,9 +314,9 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
317
314
|
}
|
|
318
315
|
},
|
|
319
316
|
[isHorizontalDragging]
|
|
320
|
-
)
|
|
317
|
+
);
|
|
321
318
|
|
|
322
|
-
const
|
|
319
|
+
const handleHorizontalThumbMouseMove = useCallback(
|
|
323
320
|
(e: React.MouseEvent) => {
|
|
324
321
|
e.preventDefault();
|
|
325
322
|
e.stopPropagation();
|
|
@@ -341,7 +338,7 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
341
338
|
}
|
|
342
339
|
},
|
|
343
340
|
[isHorizontalDragging, scrollHorizontalStartPosition, thumbWidth]
|
|
344
|
-
)
|
|
341
|
+
);
|
|
345
342
|
|
|
346
343
|
|
|
347
344
|
|
|
@@ -405,13 +402,6 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
405
402
|
|
|
406
403
|
// Listen for mouse events to handle scrolling by dragging the thumb
|
|
407
404
|
useEffect(() => {
|
|
408
|
-
document.addEventListener('mousemove', handleThumbMousemove);
|
|
409
|
-
document.addEventListener('mouseup', handleThumbMouseup);
|
|
410
|
-
document.addEventListener('mouseleave', handleThumbMouseup);
|
|
411
|
-
|
|
412
|
-
document.addEventListener('mousemove', handleHorizontalThumbMousemove);
|
|
413
|
-
document.addEventListener('mouseup', handleHorizontalThumbMouseup);
|
|
414
|
-
document.addEventListener('mouseleave', handleHorizontalThumbMouseup);
|
|
415
405
|
|
|
416
406
|
|
|
417
407
|
// Add function to the element that should be used as the scrollable area.
|
|
@@ -422,15 +412,7 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
422
412
|
}
|
|
423
413
|
|
|
424
414
|
|
|
425
|
-
|
|
426
415
|
return () => {
|
|
427
|
-
document.removeEventListener('mousemove', handleThumbMousemove);
|
|
428
|
-
document.removeEventListener('mouseup', handleThumbMouseup);
|
|
429
|
-
document.removeEventListener('mouseleave', handleThumbMouseup);
|
|
430
|
-
|
|
431
|
-
document.removeEventListener('mousemove', handleHorizontalThumbMousemove);
|
|
432
|
-
document.removeEventListener('mouseup', handleHorizontalThumbMouseup);
|
|
433
|
-
document.removeEventListener('mouseleave', handleHorizontalThumbMouseup);
|
|
434
416
|
|
|
435
417
|
if (contentRef.current) {
|
|
436
418
|
contentRef.current.removeEventListener('wheel', contentAreaScrollUpdate);
|
|
@@ -440,7 +422,7 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
440
422
|
};
|
|
441
423
|
|
|
442
424
|
|
|
443
|
-
}, [
|
|
425
|
+
}, [handleThumbMouseMove, handleThumbMouseUp, handleHorizontalThumbMouseMove, handleHorizontalThumbMouseUp]);
|
|
444
426
|
|
|
445
427
|
|
|
446
428
|
return (
|
|
@@ -455,6 +437,7 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
455
437
|
{children}
|
|
456
438
|
</div>
|
|
457
439
|
|
|
440
|
+
|
|
458
441
|
{/* SCROLLBAR */}
|
|
459
442
|
{/*
|
|
460
443
|
!!! IMPORTANT:
|
|
@@ -479,7 +462,9 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
479
462
|
<div
|
|
480
463
|
className="custom-scrollbars__thumb"
|
|
481
464
|
ref={scrollThumbRef}
|
|
482
|
-
onMouseDown={
|
|
465
|
+
onMouseDown={handleThumbMouseDown}
|
|
466
|
+
onMouseMove={handleThumbMouseMove}
|
|
467
|
+
onMouseUp={handleThumbMouseUp}
|
|
483
468
|
style={{
|
|
484
469
|
height: `${thumbHeight}px`,
|
|
485
470
|
cursor: isDragging ? 'grabbing' : 'grab',
|
|
@@ -520,7 +505,9 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|
|
520
505
|
<div
|
|
521
506
|
className="custom-scrollbars__thumb"
|
|
522
507
|
ref={scrollThumbHorizontalRef}
|
|
523
|
-
onMouseDown={
|
|
508
|
+
onMouseDown={handleHorizontalThumbMouseDown}
|
|
509
|
+
onMouseMove={handleHorizontalThumbMouseMove}
|
|
510
|
+
onMouseUp={handleHorizontalThumbMouseUp}
|
|
524
511
|
style={{
|
|
525
512
|
width: `${thumbWidth}px`,
|
|
526
513
|
cursor: isHorizontalDragging ? 'grabbing' : 'grab',
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "UIUX Lab",
|
|
3
3
|
"email": "uiuxlab@gmail.com",
|
|
4
4
|
"name": "funda-ui",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.408",
|
|
6
6
|
"description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|