react-edge-dock 1.0.7 → 1.0.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 +1 @@
1
- {"version":3,"file":"useEdgeDock.d.ts","sourceRoot":"","sources":["../src/useEdgeDock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EAId,iBAAiB,EAIlB,MAAM,SAAS,CAAC;AAwLjB;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,GAAE,cAAmB,GAAG,iBAAiB,CA2W1E"}
1
+ {"version":3,"file":"useEdgeDock.d.ts","sourceRoot":"","sources":["../src/useEdgeDock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EAId,iBAAiB,EAIlB,MAAM,SAAS,CAAC;AAwLjB;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,GAAE,cAAmB,GAAG,iBAAiB,CA8W1E"}
@@ -164,6 +164,7 @@ export function useEdgeDock(config = {}) {
164
164
  startPosX: 0,
165
165
  startPosY: 0,
166
166
  hasMoved: false,
167
+ popupWasOpen: false,
167
168
  });
168
169
  const isPopupOpen = controlledPopupOpen ?? isPopupOpenInternal;
169
170
  // Get current state
@@ -296,14 +297,11 @@ export function useEdgeDock(config = {}) {
296
297
  startPosX: position.x,
297
298
  startPosY: position.y,
298
299
  hasMoved: false,
300
+ popupWasOpen: isPopupOpen,
299
301
  };
300
302
  setIsDragging(true);
301
303
  setIsAnimating(false);
302
- // Close popup when starting to drag
303
- if (isPopupOpen) {
304
- closePopup();
305
- }
306
- }, [position, isPopupOpen, closePopup]);
304
+ }, [position, isPopupOpen]);
307
305
  // Pointer move handler
308
306
  useEffect(() => {
309
307
  const handlePointerMove = (e) => {
@@ -313,6 +311,12 @@ export function useEdgeDock(config = {}) {
313
311
  const deltaY = e.clientY - dragStateRef.current.startY;
314
312
  // Mark as moved if dragged more than 5px
315
313
  if (Math.abs(deltaX) > 5 || Math.abs(deltaY) > 5) {
314
+ if (!dragStateRef.current.hasMoved) {
315
+ // First time detecting movement - close popup if it was open
316
+ if (dragStateRef.current.popupWasOpen) {
317
+ closePopup();
318
+ }
319
+ }
316
320
  dragStateRef.current.hasMoved = true;
317
321
  }
318
322
  const newPos = {
@@ -359,7 +363,7 @@ export function useEdgeDock(config = {}) {
359
363
  document.removeEventListener('pointermove', handlePointerMove);
360
364
  document.removeEventListener('pointerup', handlePointerUp);
361
365
  };
362
- }, [position, dockMode, dockEdge, animation, edgeOffset, allowedEdges]);
366
+ }, [position, dockMode, dockEdge, animation, edgeOffset, allowedEdges, closePopup]);
363
367
  // Click handler (only trigger if not dragged)
364
368
  const handleClick = useCallback((e) => {
365
369
  if (dragStateRef.current.hasMoved) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-edge-dock",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "A zero-dependency React TypeScript library for customizable draggable edge-docked floating buttons with popup support",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",