@yogiswara/honcho-editor-ui 3.1.4 → 3.1.6
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.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Slider, Box } from '@mui/material';
|
|
3
|
-
// I've renamed the component to HThumbSlider to match our earlier convention
|
|
4
3
|
export default function HThumbSlider(props) {
|
|
5
4
|
return (
|
|
6
5
|
// This wrapper creates the positioning context for the shield.
|
|
@@ -10,9 +9,10 @@ export default function HThumbSlider(props) {
|
|
|
10
9
|
left: 0,
|
|
11
10
|
width: '100%',
|
|
12
11
|
height: '100%',
|
|
13
|
-
zIndex: 1, // Sits above the track
|
|
12
|
+
zIndex: 1, // Sits above the track
|
|
14
13
|
} }), _jsx(Slider, { ...props, sx: {
|
|
15
|
-
position
|
|
14
|
+
// By NOT setting a position here, the thumb's z-index
|
|
15
|
+
// works within the parent Box's context.
|
|
16
16
|
...props.sx,
|
|
17
17
|
} })] }));
|
|
18
18
|
}
|
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
export default function useSliderEvents(onDragStart, onDragEnd, isBatchMode) {
|
|
3
|
-
// Use a generic HTMLElement to work for both <div> and <span>
|
|
4
3
|
const elementRef = useRef(null);
|
|
5
4
|
useEffect(() => {
|
|
6
5
|
const element = elementRef.current;
|
|
7
6
|
if (!element)
|
|
8
7
|
return;
|
|
9
|
-
// This handler is attached to the WINDOW for the 'pointerup' event.
|
|
10
8
|
const handleDragEnd = () => {
|
|
11
9
|
onDragEnd();
|
|
12
|
-
// Clean up the global listener immediately after the drag ends.
|
|
13
10
|
window.removeEventListener('pointerup', handleDragEnd);
|
|
14
11
|
};
|
|
15
|
-
// This handler is attached to the slider THUMB for the 'pointerdown' event.
|
|
16
12
|
const handleDragStart = (event) => {
|
|
17
|
-
//
|
|
18
|
-
|
|
13
|
+
// DO NOT call event.preventDefault() here.
|
|
14
|
+
// This allows the MUI Slider to handle its own drag logic.
|
|
19
15
|
if (!isBatchMode) {
|
|
20
16
|
onDragStart();
|
|
21
17
|
}
|
|
22
|
-
// When dragging starts, listen on the entire window for the end.
|
|
23
18
|
window.addEventListener('pointerup', handleDragEnd);
|
|
24
19
|
};
|
|
25
|
-
// Attach a single "start" listener to the specific element (the thumb).
|
|
26
20
|
element.addEventListener('pointerdown', handleDragStart);
|
|
27
|
-
// Cleanup function when the component unmounts
|
|
28
21
|
return () => {
|
|
29
22
|
element.removeEventListener('pointerdown', handleDragStart);
|
|
30
|
-
// Ensure any lingering window listeners are also removed.
|
|
31
23
|
window.removeEventListener('pointerup', handleDragEnd);
|
|
32
24
|
};
|
|
33
25
|
}, [onDragStart, onDragEnd, isBatchMode]);
|