Sha256: 3686ca8c37da685ebedf98ae9dcff8fdccfc6d5eade677030adf1209bfed512c
Contents?: true
Size: 980 Bytes
Versions: 1
Compression:
Stored size: 980 Bytes
Contents
import { RefObject } from "react"; import * as Drag from "../../types/Drag"; import * as Images from "../../types/Images"; type Props = { container: RefObject<HTMLDivElement>; draggable: Drag.DraggableOrFiles<Images.Record>; dragState: Drag.State<Images.Record>; }; export default function DragElement(props: Props) { const { draggable, dragState, container } = props; if (draggable === "Files") { return ""; } else if (typeof draggable !== "string") { const record = draggable.record; const containerSize = container.current.getBoundingClientRect(); const x = dragState.x - (containerSize.x || containerSize.left); const y = dragState.y - (containerSize.y || containerSize.top); const translateStyle = { transform: `translate3d(${x}px, ${y}px, 0)` }; return ( <div className="drag-image" style={translateStyle}> {record.image && <img src={record.src || record.image.thumbnail_url} />} </div> ); } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pages_core-3.15.5 | app/javascript/components/ImageGrid/DragElement.tsx |