mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
38 lines
812 B
TypeScript
38 lines
812 B
TypeScript
import { useEffect, useRef } from "react";
|
|
import { LaserPathManager } from "./LaserPathManager";
|
|
import "./LaserToolOverlay.scss";
|
|
import { UIAppState } from "../../types";
|
|
|
|
type LaserToolOverlayProps = {
|
|
manager: LaserPathManager;
|
|
appState: UIAppState;
|
|
};
|
|
|
|
export const LaserToolOverlay = ({
|
|
manager,
|
|
appState,
|
|
}: LaserToolOverlayProps) => {
|
|
const svgRef = useRef<SVGSVGElement | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (svgRef.current) {
|
|
manager.start(svgRef.current);
|
|
}
|
|
|
|
return () => {
|
|
manager.stop();
|
|
};
|
|
}, [manager]);
|
|
|
|
return (
|
|
<div
|
|
className="LaserToolOverlay"
|
|
style={{
|
|
top: `-${appState.offsetTop}px`,
|
|
left: `-${appState.offsetLeft}px`,
|
|
}}
|
|
>
|
|
<svg ref={svgRef} className="LaserToolOverlayCanvas" />
|
|
</div>
|
|
);
|
|
};
|