traffic light makes even more sounds

This commit is contained in:
Joeri Exelmans 2025-10-31 15:46:11 +01:00
parent 39b286bffe
commit 6a12ba5341
2 changed files with 11 additions and 1 deletions

View file

@ -4,6 +4,7 @@ import imgRedOverlay from "./red-overlay.webp";
import imgYellowOverlay from "./yellow-overlay.webp";
import imgGreenOverlay from "./green-overlay.webp";
import sndAtmosphere from "./atmosphere.opus";
import sndBuzz from "./buzz.wav";
import { preload } from "react-dom";
import trafficLightConcreteSyntax from "./model.json";
@ -45,6 +46,15 @@ export const TrafficLight = memo(function TrafficLight({state, speed, raiseUIEve
return () => stopPlaying();
}, []);
useEffect(() => {
if (redOn || yellowOn || greenOn) {
const stopPlaying = playURL(sndBuzz, true);
return () => {
stopPlaying();
};
}
}, [redOn || yellowOn || greenOn])
return <>
<style>{`
@font-face{
@ -52,7 +62,7 @@ export const TrafficLight = memo(function TrafficLight({state, speed, raiseUIEve
src: url(${fontDigital});
}
image {
transition: opacity 250ms ease;
transition: opacity 300ms ease;
}
.hidden {
opacity: 0;

Binary file not shown.