@hydroperx/drag4react
Advanced tools
+10
-9
| import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; | ||
| import { useEffect } from "react"; | ||
| import { useEffect, useRef } from "react"; | ||
| import BaseDraggable from "@hydroperx/draggable"; | ||
| export default function Draggable(options) { | ||
| let { dragStart: drag_start, dragMove: drag_move, dragStop: drag_stop, limitRef: limit_ref, nodeRef: el_ref, children, disabled, } = options; | ||
| let draggable = null; | ||
| const draggable = useRef(null); | ||
| function create_draggable() { | ||
| draggable = new BaseDraggable(el_ref.current, { | ||
| draggable.current = new BaseDraggable(el_ref.current, { | ||
| limit: limit_ref.current ?? undefined, | ||
@@ -22,4 +22,5 @@ onDragStart(element, x, y, event) { | ||
| useEffect(() => { | ||
| if (draggable) | ||
| draggable.destroy(), draggable = null; | ||
| if (draggable.current) | ||
| draggable.current.destroy(), | ||
| draggable.current = null; | ||
| if (!disabled) | ||
@@ -29,4 +30,4 @@ create_draggable(); | ||
| return () => { | ||
| if (draggable) | ||
| draggable.destroy(), draggable = null; | ||
| if (draggable.current) | ||
| draggable.current.destroy(), draggable.current = null; | ||
| }; | ||
@@ -37,4 +38,4 @@ }, [disabled]); | ||
| return () => { | ||
| if (draggable) | ||
| draggable.destroy(), draggable = null; | ||
| if (draggable.current) | ||
| draggable.current.destroy(), draggable.current = null; | ||
| }; | ||
@@ -41,0 +42,0 @@ }, []); |
+1
-1
| { | ||
| "name": "@hydroperx/drag4react", | ||
| "version": "1.1.1", | ||
| "version": "1.1.2", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "files": ["/dist"], |
14914
0.77%56
1.82%