From 7c46df1c3026b5d836bc082e5e1dc2cdd093b77c Mon Sep 17 00:00:00 2001 From: Daybrush Date: Tue, 16 May 2023 01:42:31 +0900 Subject: [PATCH] feat: add drag api demo --- .../stories/99-Tests/ReactDragAPIApp.tsx | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 packages/react-moveable/stories/99-Tests/ReactDragAPIApp.tsx diff --git a/packages/react-moveable/stories/99-Tests/ReactDragAPIApp.tsx b/packages/react-moveable/stories/99-Tests/ReactDragAPIApp.tsx new file mode 100644 index 000000000..ba85091fd --- /dev/null +++ b/packages/react-moveable/stories/99-Tests/ReactDragAPIApp.tsx @@ -0,0 +1,44 @@ +import React, { useEffect, useRef, useState } from "react"; +import Moveable from "@/react-moveable"; + + +export default function App() { + const moveableRef = useRef(null); + const [target, setTarget] = useState(null); + + return ( +
+
{ + const nativeEvent = e.nativeEvent; + + if (!target) { + moveableRef.current!.waitToChangeTarget().then(() => { + moveableRef.current!.dragStart(nativeEvent); + }); + setTarget(document.querySelector("#drag1")); + } + }}>
+ { + e.preventDefault(); + }} + /> + { + e.target.style.cssText += e.cssText; + }} + /> +
+ ); +}