import React, { Component, SyntheticEvent } from "react"; import { Rnd } from "react-rnd"; import "../style/AreaHighlight.css"; import { T_LTWH, T_ViewportHighlight } from "../types"; interface Props { highlight: T_ViewportHighlight; onChange: (rect: T_LTWH) => void; isScrolledTo: boolean; disableEdit?: boolean; } class AreaHighlight extends Component { render() { const { highlight, onChange, isScrolledTo, disableEdit, ...otherProps } = this.props; return (
{ const boundingRect = { ...highlight.position.boundingRect, top: data.y, left: data.x, }; onChange(boundingRect); }} onResizeStop={(_, direction, ref, delta, position) => { const boundingRect = { top: position.y, left: position.x, width: ref.offsetWidth, height: ref.offsetHeight, }; onChange(boundingRect); }} position={{ x: highlight.position.boundingRect.left, y: highlight.position.boundingRect.top, }} size={{ width: highlight.position.boundingRect.width, height: highlight.position.boundingRect.height, }} onClick={(event: SyntheticEvent) => { event.stopPropagation(); event.preventDefault(); }} {...otherProps} />
); } } export default AreaHighlight;