laser+collaboration: indicate which shapes are being pointed at

mime/laser-experiment
Mime Čuvalo 2024-04-26 15:59:21 +01:00
rodzic de55259c92
commit 689b5e321a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: BA84499022AC984D
1 zmienionych plików z 29 dodań i 0 usunięć

Wyświetl plik

@ -94,6 +94,34 @@ const Collaborator = track(function Collaborator({
cursor.y > viewportPageBounds.maxY - 16 / zoomLevel
)
let laserIndicatedShapeIndicator
// Highlight shapes that are being pointed at by the laser.
if (
CollaboratorScribble &&
CollaboratorShapeIndicator &&
scribbles.length === 1 &&
scribbles[0].color === 'laser'
) {
for (const shape of editor.getCurrentPageShapes()) {
const shapeId = shape.id
if (
editor.getShapeGeometry(shape).isPointInBounds(editor.getPointInShapeSpace(shape, cursor))
) {
laserIndicatedShapeIndicator = (
<CollaboratorShapeIndicator
className="tl-collaborator__shape-indicator"
key={userId + '_' + shapeId}
shapeId={shapeId}
color={color}
opacity={1}
/>
)
break
}
}
}
return (
<>
{brush && CollaboratorBrush ? (
@ -137,6 +165,7 @@ const Collaborator = track(function Collaborator({
opacity={scribble.color === 'laser' ? 0.5 : 0.1}
/>
))}
{laserIndicatedShapeIndicator}
</>
) : null}
{CollaboratorShapeIndicator &&