From b942993697288e32ebc3c02407edc59dfd208e15 Mon Sep 17 00:00:00 2001 From: Eduardo Mazarrasa Date: Sat, 10 Jan 2026 00:12:40 +0100 Subject: [PATCH 1/3] test vibrate 1 --- hooks/useAudioController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/hooks/useAudioController.ts b/hooks/useAudioController.ts index c75de32..8ac8937 100644 --- a/hooks/useAudioController.ts +++ b/hooks/useAudioController.ts @@ -67,6 +67,7 @@ export const useAudioController = ({ phase, timeDiff }: UseAudioControllerProps) if (currentChimeIndex !== prevChimeIndexRef.current && currentChimeIndex < 12) { audioService.playChime(); + navigator.vibrate([200, 200]); prevChimeIndexRef.current = currentChimeIndex; } } From 3b3bf574a08f946945b68640bbb03a151c63b6c9 Mon Sep 17 00:00:00 2001 From: Eduardo Mazarrasa Date: Sat, 10 Jan 2026 00:41:53 +0100 Subject: [PATCH 2/3] test vibrando 2 --- App.tsx | 18 +++++++++++++++++- hooks/useAudioController.ts | 17 +++++++++++++++-- hooks/useCampanadasTimer.ts | 17 +++++++++++++++-- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/App.tsx b/App.tsx index bf1a2ba..eaee131 100644 --- a/App.tsx +++ b/App.tsx @@ -59,6 +59,7 @@ const App: React.FC = () => { const startPos = { x: grapeRect.left + grapeRect.width / 2, y: grapeRect.top + grapeRect.height / 2 }; const endPos = { x: mouthRect.left + mouthRect.width / 2, y: mouthRect.top + mouthRect.height / 2 }; setFlyingGrapes(prev => [...prev, { id: Date.now(), startPos, endPos }]); + vibrarTelefono([200, 200]); } // 2. Scoring Logic @@ -78,6 +79,18 @@ const App: React.FC = () => { }, [timeDiff, grapeStatus, lastCorrectChime]); + const vibrarTelefono = (pattern) => { + console.log("Vibrando", pattern); + if ("vibrate" in navigator) { + // Intentar vibrar 500ms + const exito = navigator.vibrate(pattern); + if (!exito) { + console.log("La vibración fue bloqueada o no es compatible."); + } + } else { + console.log("Tu navegador no soporta la API de vibración."); + } + }; const startTest = () => { audioService.init(); @@ -85,6 +98,7 @@ const App: React.FC = () => { const now = Date.now(); const target = TARGET_DATE.getTime(); setOffsetTime(target - 40000 - now); + vibrarTelefono([200, 200]); }; const getPhaseText = () => { @@ -124,6 +138,7 @@ const App: React.FC = () => { text: '¡Aún no ansioso!, espera a que empiecen las campanadas.', duration: EARLY_CLICK_MODAL_AUTO_CLOSE_MS }); + vibrarTelefono([200, 200]); }, []); const showInstructionsMessage = useCallback(() => { @@ -131,6 +146,7 @@ const App: React.FC = () => { text: 'Vamos a empezar bien el año!!! 🥳 Espera a que empiecen las campanadas y toca cada uva cuando suene la campana.', duration: INSTRUCTIONS_MODAL_AUTO_CLOSE_MS }); + vibrarTelefono([200, 200]); }, []); const handleOverlayClose = useCallback(() => { @@ -210,7 +226,7 @@ const App: React.FC = () => { /> - {/* Grapes Grid & Message Overlay Container */} + {/* Grapes Grid */}
= 0 && quarterIdx < 4 && quarterIdx !== prevQuarterIndexRef.current) { audioService.playQuarter(); prevQuarterIndexRef.current = quarterIdx; } } + function vibrarTelefono(pattern) { + console.log("Vibrando", pattern); + if ("vibrate" in navigator) { + // Intentar vibrar 500ms + const exito = navigator.vibrate(pattern); + if (!exito) { + console.log("La vibración fue bloqueada o no es compatible."); + } + } else { + console.log("Tu navegador no soporta la API de vibración."); + } + } + // 3. Chimes Logic if (phase === AppPhase.CHIMES) { const msSinceMidnight = Math.abs(timeDiff); @@ -67,7 +80,7 @@ export const useAudioController = ({ phase, timeDiff }: UseAudioControllerProps) if (currentChimeIndex !== prevChimeIndexRef.current && currentChimeIndex < 12) { audioService.playChime(); - navigator.vibrate([200, 200]); + // vibrarTelefono([200, 200]); prevChimeIndexRef.current = currentChimeIndex; } } diff --git a/hooks/useCampanadasTimer.ts b/hooks/useCampanadasTimer.ts index 3bf6fe2..e1a6cd8 100644 --- a/hooks/useCampanadasTimer.ts +++ b/hooks/useCampanadasTimer.ts @@ -25,9 +25,22 @@ export const useCampanadasTimer = ({ offsetTime }: UseCampanadasTimerProps) => { const [chimeCount, setChimeCount] = useState(0); const [timeDiff, setTimeDiff] = useState(0); + const vibrarTelefono = (pattern) => { + console.log("Vibrando", pattern); + if ("vibrate" in navigator) { + // Intentar vibrar 500ms + const exito = navigator.vibrate(pattern); + if (!exito) { + console.log("La vibración fue bloqueada o no es compatible."); + } + } else { + console.log("Tu navegador no soporta la API de vibración."); + } + }; + useEffect(() => { let animationFrameId: number; - + vibrarTelefono([300, 300]); const updateTime = () => { const now = Date.now() + offsetTime; const visualDate = new Date(now); @@ -68,7 +81,7 @@ export const useCampanadasTimer = ({ offsetTime }: UseCampanadasTimerProps) => { const currentChimeIndex = Math.floor(msSinceMidnight / CHIME_INTERVAL); setChimeCount(currentChimeIndex + 1); } else if (currentPhase !== AppPhase.CELEBRATION) { - if (currentPhase === AppPhase.COUNTDOWN) { + if (currentPhase === AppPhase.COUNTDOWN) { setChimeCount(0); } } From e1035636aba5e993432e333af1bf651e38bc34a6 Mon Sep 17 00:00:00 2001 From: Eduardo Mazarrasa Date: Sat, 10 Jan 2026 00:55:04 +0100 Subject: [PATCH 3/3] test vibrate 3 --- hooks/useCampanadasTimer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/useCampanadasTimer.ts b/hooks/useCampanadasTimer.ts index e1a6cd8..54f3cc7 100644 --- a/hooks/useCampanadasTimer.ts +++ b/hooks/useCampanadasTimer.ts @@ -40,7 +40,7 @@ export const useCampanadasTimer = ({ offsetTime }: UseCampanadasTimerProps) => { useEffect(() => { let animationFrameId: number; - vibrarTelefono([300, 300]); + // vibrarTelefono([300, 300]); const updateTime = () => { const now = Date.now() + offsetTime; const visualDate = new Date(now);