import React, { useRef } from "react" import Draggable from "react-draggable" import { BallPiece } from "./BallPiece" import { NULL_POS } from "../../geo/Pos" import { Ball } from "../../model/tactic/CourtObjects" export interface CourtBallProps { onPosValidated: (rect: DOMRect) => void onRemove: () => void ball: Ball } export function CourtBall({ onPosValidated, ball, onRemove }: CourtBallProps) { const pieceRef = useRef(null) const x = ball.rightRatio const y = ball.bottomRatio return ( onPosValidated(pieceRef.current!.getBoundingClientRect()) } position={NULL_POS} nodeRef={pieceRef}>
{ if (e.key == "Delete") onRemove() }} style={{ position: "absolute", left: `${x * 100}%`, top: `${y * 100}%`, }}>
) }