1 import OpenSeadragon from 'openseadragon';
2 import PropTypes from 'prop-types';
3 import React from 'react';
4 import { createPortal } from 'react-dom';
6 import { useOpenSeadragon } from './OpenSeadragon';
8 const Overlay = ({ children, onClick, x, y }) => {
9 const { viewer } = useOpenSeadragon();
10 const [element] = React.useState(document.createElement('div'));
12 React.useEffect(() => {
16 new OpenSeadragon.Point(x, y),
17 OpenSeadragon.Placement.CENTER,
20 new OpenSeadragon.MouseTracker({
22 clickHandler: onClick,
25 }, [onClick, viewer, x, y]);
27 return createPortal(children, element);
31 children: PropTypes.node,
32 onClick: PropTypes.func,
37 export default Overlay;