@yogiswara/honcho-editor-ui 3.0.0 → 3.0.2

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.
@@ -88,7 +88,7 @@ export default function HSliderColorMobile(props) {
88
88
  console.log('[HSliderColorMobile TEMPERATURE] SLIDER onDragEnd triggered.');
89
89
  props.onDragEnd();
90
90
  };
91
- const tempSliderRef = useSliderEvents(handleDragStartWithLog, handleDragEndWithLog, props.isBatchMode);
91
+ const tempSliderRef = useSliderEvents(props.onDragStart, props.onDragEnd, props.isBatchMode);
92
92
  const tintSliderRef = useSliderEvents(props.onDragStart, props.onDragEnd, props.isBatchMode);
93
93
  const vibranceSliderRef = useSliderEvents(props.onDragStart, props.onDragEnd, props.isBatchMode);
94
94
  const saturationSliderRef = useSliderEvents(props.onDragStart, props.onDragEnd, props.isBatchMode);
@@ -1 +1 @@
1
- export default function useSliderEvents(onDragStart: () => void, onDragEnd: () => void, isBatchMode: boolean): import("react").RefObject<HTMLSpanElement>;
1
+ export default function useSliderEvents(onDragStart: () => void, onDragEnd: () => void, isBatchMode: boolean): import("react").RefObject<HTMLElement>;
@@ -1,37 +1,38 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  export default function useSliderEvents(onDragStart, onDragEnd, isBatchMode) {
3
- const sliderRef = useRef(null);
3
+ // Use a generic HTMLElement to work for both <div> and <span>
4
+ const elementRef = useRef(null);
4
5
  useEffect(() => {
5
- const slider = sliderRef.current;
6
- if (!slider)
6
+ const element = elementRef.current;
7
+ if (!element)
7
8
  return;
8
- // This function will be attached to the WINDOW to listen for the end of a drag.
9
+ // This handler is attached to the WINDOW to reliably catch the end of the drag.
9
10
  const handleDragEnd = () => {
10
11
  onDragEnd();
11
- // IMPORTANT: Clean up the global listeners immediately after the drag ends.
12
+ // Clean up the global listeners immediately after they fire.
12
13
  window.removeEventListener('mouseup', handleDragEnd);
13
14
  window.removeEventListener('touchend', handleDragEnd);
14
15
  };
15
- // This function is attached ONLY to the slider thumb to start a drag.
16
+ // This handler is attached to the slider THUMB to start the drag.
16
17
  const handleDragStart = () => {
17
18
  if (!isBatchMode) {
18
19
  onDragStart();
19
20
  }
20
- // When a drag starts, attach the listeners to the window to catch the end.
21
+ // When dragging starts, listen on the entire window for the end.
21
22
  window.addEventListener('mouseup', handleDragEnd);
22
23
  window.addEventListener('touchend', handleDragEnd);
23
24
  };
24
- // Attach the "start" listeners to the slider thumb.
25
- slider.addEventListener('mousedown', handleDragStart);
26
- slider.addEventListener('touchstart', handleDragStart, { passive: true });
27
- // The main cleanup function for when the component unmounts.
25
+ // Attach "start" listeners to the specific element (the thumb).
26
+ element.addEventListener('mousedown', handleDragStart);
27
+ element.addEventListener('touchstart', handleDragStart, { passive: true });
28
+ // Cleanup function when the component unmounts.
28
29
  return () => {
29
- slider.removeEventListener('mousedown', handleDragStart);
30
- slider.removeEventListener('touchstart', handleDragStart);
31
- // Also remove any lingering window listeners, just in case.
30
+ element.removeEventListener('mousedown', handleDragStart);
31
+ element.removeEventListener('touchstart', handleDragStart);
32
+ // Ensure any lingering window listeners are also removed.
32
33
  window.removeEventListener('mouseup', handleDragEnd);
33
34
  window.removeEventListener('touchend', handleDragEnd);
34
35
  };
35
36
  }, [onDragStart, onDragEnd, isBatchMode]);
36
- return sliderRef;
37
+ return elementRef;
37
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "A complete UI component library for the Honcho photo editor.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",