@yogiswara/honcho-editor-ui 2.10.10 → 2.10.11

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 +1,2 @@
1
- export default function useSliderEvents(onDragStart: () => void, onDragEnd: () => void, isBatchMode: boolean): import("react").RefObject<HTMLSpanElement>;
1
+ import React from "react";
2
+ export default function useSliderEvents(onDragStart: () => void, onDragEnd: () => void, isBatchMode: boolean): React.RefObject<HTMLSpanElement>;
@@ -2,36 +2,31 @@ import { useEffect, useRef } from "react";
2
2
  export default function useSliderEvents(onDragStart, onDragEnd, isBatchMode) {
3
3
  const sliderRef = useRef(null);
4
4
  useEffect(() => {
5
- const sliderElement = sliderRef.current;
6
- if (!sliderElement)
5
+ const slider = sliderRef.current;
6
+ if (!slider)
7
7
  return;
8
- const handleStart = (e) => {
9
- // THE FIX: Stop the event from bubbling up and causing conflicts.
10
- e.stopPropagation();
8
+ // A single handler for starting the drag
9
+ const handleStart = () => {
11
10
  if (!isBatchMode) {
12
11
  onDragStart();
13
12
  }
14
- // Add "end" listeners to the whole document when a drag starts
15
- document.addEventListener("mouseup", handleEnd);
16
- document.addEventListener("touchend", handleEnd);
17
13
  };
18
- const handleEnd = (e) => {
19
- // It's good practice to also stop propagation on the end event
20
- e.stopPropagation();
14
+ // A single handler for ending the drag
15
+ const handleEnd = () => {
21
16
  onDragEnd();
22
- // IMPORTANT: Remove the "end" listeners from the document to clean up
23
- document.removeEventListener("mouseup", handleEnd);
24
- document.removeEventListener("touchend", handleEnd);
25
17
  };
26
- // Listen for the "start" events on the slider itself
27
- sliderElement.addEventListener("mousedown", handleStart);
28
- sliderElement.addEventListener("touchstart", handleStart, { passive: true });
29
- // Cleanup function to remove all listeners when the component unmounts
18
+ // Listen for BOTH mouse and touch start events
19
+ slider.addEventListener('mousedown', handleStart);
20
+ slider.addEventListener('touchstart', handleStart, { passive: true });
21
+ // Listen for BOTH mouse and touch end events
22
+ slider.addEventListener('mouseup', handleEnd);
23
+ slider.addEventListener('touchend', handleEnd, { passive: true });
24
+ // Cleanup function to remove all listeners
30
25
  return () => {
31
- sliderElement.removeEventListener("mousedown", handleStart);
32
- sliderElement.removeEventListener("touchstart", handleStart);
33
- document.removeEventListener("mouseup", handleEnd);
34
- document.removeEventListener("touchend", handleEnd);
26
+ slider.removeEventListener('mousedown', handleStart);
27
+ slider.removeEventListener('touchstart', handleStart);
28
+ slider.removeEventListener('mouseup', handleEnd);
29
+ slider.removeEventListener('touchend', handleEnd);
35
30
  };
36
31
  }, [onDragStart, onDragEnd, isBatchMode]);
37
32
  return sliderRef;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "2.10.10",
3
+ "version": "2.10.11",
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",