mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-08-23 18:26:54 +02:00

* feat: initial Laser pointer mvp * feat: add laser-pointer package and integrate it with collab * chore: fix yarn.lock * feat: update laser-pointer package, prevent panning from showing * feat: add laser pointer tool button when collaborating, migrate to official package * feat: reduce laser tool button size * update icon * fix icon & rotate * fix: lock zoom level * fix icon * add `selected` state, simplify and reduce api * set up pointer callbacks in viewMode if laser tool active * highlight extra-tools button if one of the nested tools active * add shortcut to laser pointer * feat: don't update paths if nothing changed * ensure we reset flag if no rAF scheduled * move `lastUpdate` to instance to optimize * return early * factor out into constants and add doc * skip iteration instead of exit * fix naming * feat: remove testing variable on window * destroy on editor unmount * fix incorrectly resetting `lastUpdate` in `stop()` --------- Co-authored-by: dwelle <luzar.david@gmail.com>
28 lines
612 B
TypeScript
28 lines
612 B
TypeScript
import { useEffect, useRef } from "react";
|
|
import { LaserPathManager } from "./LaserPathManager";
|
|
import "./LaserToolOverlay.scss";
|
|
|
|
type LaserToolOverlayProps = {
|
|
manager: LaserPathManager;
|
|
};
|
|
|
|
export const LaserToolOverlay = ({ manager }: LaserToolOverlayProps) => {
|
|
const svgRef = useRef<SVGSVGElement | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (svgRef.current) {
|
|
manager.start(svgRef.current);
|
|
}
|
|
|
|
return () => {
|
|
manager.stop();
|
|
};
|
|
}, [manager]);
|
|
|
|
return (
|
|
<div className="LaserToolOverlay">
|
|
<svg ref={svgRef} className="LaserToolOverlayCanvas" />
|
|
</div>
|
|
);
|
|
};
|