@yogiswara/honcho-editor-ui 2.10.6 → 2.10.8

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,2 +1,2 @@
1
1
  import React from "react";
2
- export default function useSliderEvents(onDragStart: () => void, onDragEnd: () => void, isBatchMode: boolean): React.RefObject<HTMLDivElement>;
2
+ export default function useSliderEvents(onDragStart: () => void, onDragEnd: () => void, isBatchMode: boolean): React.RefObject<HTMLSpanElement>;
@@ -1,50 +1,39 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  export default function useSliderEvents(onDragStart, onDragEnd, isBatchMode) {
3
3
  const sliderRef = useRef(null);
4
- console.log("BATCH MODE CALLED?", isBatchMode);
5
- console.log("SLIDEREVENT CALLED START!", onDragStart);
6
- console.log("SLIDEREVENT CALLED END!", onDragEnd);
7
4
  useEffect(() => {
8
- const sliderElement = sliderRef.current;
9
- if (!sliderElement)
5
+ const slider = sliderRef.current;
6
+ if (!slider)
10
7
  return;
11
- const handleMouseDown = () => {
8
+ // A single handler for starting the drag
9
+ const handleStart = () => {
12
10
  if (!isBatchMode) {
13
11
  onDragStart();
14
12
  }
15
- // Add document listeners when dragging starts
16
- document.addEventListener("mouseup", handleMouseUp);
17
- document.addEventListener("touchend", handleTouchEnd);
13
+ document.addEventListener("mouseup", handleEnd);
14
+ document.addEventListener("touchend", handleEnd);
18
15
  };
19
- const handleTouchStart = () => {
20
- if (!isBatchMode) {
21
- onDragStart();
22
- }
23
- // Add document listeners when dragging starts
24
- document.addEventListener("mouseup", handleMouseUp);
25
- document.addEventListener("touchend", handleTouchEnd);
26
- };
27
- const handleMouseUp = () => {
28
- onDragEnd();
29
- // Remove document listeners when dragging ends
30
- document.removeEventListener("mouseup", handleMouseUp);
31
- document.removeEventListener("touchend", handleTouchEnd);
32
- };
33
- const handleTouchEnd = () => {
16
+ // A single handler for ending the drag
17
+ const handleEnd = () => {
34
18
  onDragEnd();
35
- // Remove document listeners when dragging ends
36
- document.removeEventListener("mouseup", handleMouseUp);
37
- document.removeEventListener("touchend", handleTouchEnd);
19
+ document.removeEventListener("mouseup", handleEnd);
20
+ document.removeEventListener("touchend", handleEnd);
38
21
  };
39
- sliderElement.addEventListener("mousedown", handleMouseDown);
40
- sliderElement.addEventListener("touchstart", handleTouchStart);
22
+ // Listen for BOTH mouse and touch start events
23
+ slider.addEventListener('mousedown', handleStart);
24
+ slider.addEventListener('touchstart', handleStart, { passive: true });
25
+ // Listen for BOTH mouse and touch end events
26
+ slider.addEventListener('mouseup', handleEnd);
27
+ slider.addEventListener('touchend', handleEnd, { passive: true });
28
+ // Cleanup function to remove all listeners
41
29
  return () => {
42
- sliderElement.removeEventListener("mousedown", handleMouseDown);
43
- sliderElement.removeEventListener("touchstart", handleTouchStart);
44
- // Clean up any remaining document listeners
45
- document.removeEventListener("mouseup", handleMouseUp);
46
- document.removeEventListener("touchend", handleTouchEnd);
30
+ slider.removeEventListener('mousedown', handleStart);
31
+ slider.removeEventListener('touchstart', handleStart);
32
+ slider.removeEventListener('mouseup', handleEnd);
33
+ slider.removeEventListener('touchend', handleEnd);
34
+ document.removeEventListener("mouseup", handleEnd);
35
+ document.removeEventListener("touchend", handleEnd);
47
36
  };
48
37
  }, [onDragStart, onDragEnd, isBatchMode]);
49
- return sliderRef; // Return the ref to be attached to the slider
38
+ return sliderRef;
50
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "2.10.6",
3
+ "version": "2.10.8",
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",