Skip to content

Commit

Permalink
Add mouseover and mouseout effect on vessels
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasGLund99 committed Nov 7, 2024
1 parent 4d544ca commit 2852d71
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/components/vesselMarkerOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export default function VesselMarkerOverlay({ simpleVessels, monitoredVessels }:
setSelectedVesselmmsi((selectedVesselmmsi) =>
selectedVesselmmsi === vessel.simpleVessel.mmsi ? undefined : vessel.simpleVessel.mmsi
)

markerOptions.push(
displayVesselToSpriteMarkerOption(
vessel,
Expand All @@ -80,7 +79,8 @@ export default function VesselMarkerOverlay({ simpleVessels, monitoredVessels }:
circleTexture,
selectedCircleTexture,
selectedVesselmmsi === vessel.simpleVessel.mmsi,
onClick
onClick,
() => overlay.redraw()
)
)
}
Expand Down Expand Up @@ -139,7 +139,8 @@ function displayVesselToSpriteMarkerOption(
circleTexture: PIXI.Texture,
selectedCircleTexture: PIXI.Texture,
isSelected: boolean,
onClick: () => void
onClick: () => void,
redraw: () => void
): ISpriteMarkerOptions {
const { simpleVessel, monitoredInfo } = vessel

Expand All @@ -165,6 +166,14 @@ function displayVesselToSpriteMarkerOption(
sprite.eventMode = 'dynamic'
sprite.cursor = 'pointer'
sprite.on('click', onClick)
sprite.on('mouseover', () => {
sprite.alpha = monitoredInfo ? 1 : 0.7
redraw()
})
sprite.on('mouseout', () => {
sprite.alpha = monitoredInfo ? 1 : 0.3
redraw()
})

const size = isSelected ? 20 : 13
const position: L.LatLngTuple = [simpleVessel.location.point.lat, simpleVessel.location.point.lon]
Expand Down

0 comments on commit 2852d71

Please sign in to comment.