import * as React from "react"; import Moveable from "@/react-moveable"; export default function App(props: Record) { const widthInputRef = React.useRef(null); const heightInputRef = React.useRef(null); const moveableRef = React.useRef(null); const onInput = (e: any) => { const ev = (e.nativeEvent || e) as InputEvent; const horizontal = JSON.parse((ev.target as HTMLElement).getAttribute("data-horizontal")!); if (typeof ev.data === "undefined") { moveableRef.current!.request("resizable", { offsetWidth: parseFloat(widthInputRef.current!.value), offsetHeight: parseFloat(heightInputRef.current!.value), horizontal, }, true); } }; const onKeyUp = (e: any) => { const ev = (e.nativeEvent || e) as InputEvent; const horizontal = JSON.parse((ev.target as HTMLElement).getAttribute("data-horizontal")!); e.stopPropagation(); // enter if (e.keyCode === 13) { moveableRef.current!.request("resizable", { offsetWidth: parseFloat(widthInputRef.current!.value), offsetHeight: parseFloat(heightInputRef.current!.value), horizontal, }, true); } }; return
width:   height:
Target1
Target2
Target3
{ setMin([props.minWidth, props.minHeight]); setMax([props.maxWidth, props.maxHeight]); }} onResizeGroup={({ events }) => { events.forEach(ev => { ev.target.style.width = `${ev.boundingWidth}px`; ev.target.style.height = `${ev.boundingHeight}px`; ev.target.style.transform = `translate(${ev.drag.beforeTranslate[0]}px, ${ev.drag.beforeTranslate[1]}px)`; }); }} onResizeGroupEnd={(e) => { requestAnimationFrame(() => { const rect = e.moveable.getRect(); widthInputRef.current!.value = `${rect.offsetWidth}`; heightInputRef.current!.value = `${rect.offsetHeight}`; }); }} onDragGroup={({ events }) => { events.forEach(ev => { ev.target.style.transform = ev.transform; }); }} />
; }