Skip to content

Commit 7efab03

Browse files
VolksRat71claude
andcommitted
Add mobile support for all animation steps
- RSCStep: Fixed flow track height to 120px on mobile, added vertical packet/chunk movement, hide suspense boundary, add MobileCaption and auto-scroll support - ExploitStep: Added MobileCaption, auto-scroll, and sticky controls padding - FixStep: Added MobileCaption, auto-scroll, and sticky controls padding - LessonsStep: Added MobileCaption, auto-scroll, and sticky controls padding - Updated autoScroll.ts with getExploitScrollTarget and improved getRSCScrollTarget All steps now have consistent mobile experience with: - Sticky video controls at bottom - Mobile captions in the controls slot - Auto-scroll following animation phases - Proper padding to avoid content being hidden 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bdc95b7 commit 7efab03

5 files changed

Lines changed: 289 additions & 21 deletions

File tree

‎src/lib/components/steps/ExploitStep.svelte‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44
import StepNavigation from '../StepNavigation.svelte';
55
import VideoControls from '../VideoControls.svelte';
66
import WordCaption from '../WordCaption.svelte';
7+
import MobileCaption from '../MobileCaption.svelte';
78
import { exploitTimeline, getAnimationState, type StepTimeline } from '$lib/stores/timeline.svelte';
89
import { whisperToCaptions, extractExploitKeyframeTriggers, getAudioDuration, getAllWords, type WhisperOutput, type WhisperWord } from '$lib/utils/whisper-parser';
910
import { comprehension, loadWhisperData } from '$lib/stores/comprehension.svelte';
1011
import { onMount, tick } from 'svelte';
12+
import { getExploitScrollTarget, scrollToTarget, resetScrollTracking, type ScrollTarget } from '$lib/utils/autoScroll';
1113
1214
// Loading state for lazy loading
1315
let isLoading = $state(true);
1416
let loadError = $state<string | null>(null);
1517
18+
// Container ref for auto-scrolling on mobile
19+
let animationContainer = $state<HTMLElement | null>(null);
20+
1621
// Current whisper data - loaded lazily
1722
let whisper = $state<WhisperOutput | null>(null);
1823
let captions = $derived(whisper ? whisperToCaptions(whisper) : []);
@@ -288,6 +293,26 @@
288293
// Derive animation state from currentTime - build keyframes inline to ensure reactivity
289294
let animState = $derived(getAnimationState(exploitTimeline.currentTime, buildKeyframes(triggers), INITIAL_STATE));
290295
296+
// Derive the scroll target from animation state
297+
let scrollTarget = $derived(getExploitScrollTarget({
298+
phase: animState.activeStage?.toString() ?? '',
299+
payloadSent: animState.packetVisible,
300+
serverCompromised: animState.serverStatusClass === 'danger'
301+
}));
302+
303+
// Auto-scroll on mobile when animation phase changes
304+
$effect(() => {
305+
const target = scrollTarget;
306+
if (!exploitTimeline.playing || !animationContainer) return;
307+
scrollToTarget(animationContainer, target, { minIntervalMs: 1200 });
308+
});
309+
310+
// Reset scroll tracking when component mounts/unmounts
311+
onMount(() => {
312+
resetScrollTracking();
313+
return () => resetScrollTracking();
314+
});
315+
291316
// Derive terminal lines from phase
292317
let terminalLines = $derived(getTerminalLines(animState.terminalPhase));
293318
@@ -341,7 +366,7 @@
341366
</div>
342367
{/if}
343368

344-
<div class="animation-container" class:loading={isLoading}>
369+
<div class="animation-container" class:loading={isLoading} bind:this={animationContainer}>
345370
<div class="exploit-visualization">
346371
<!-- Attacker -->
347372
<div class="exploit-entity attacker-entity">
@@ -452,7 +477,14 @@
452477
onToggleCaptions={() => exploitTimeline.toggleCaptions()}
453478
onPlaybackRateChange={(r) => exploitTimeline.setPlaybackRate(r)}
454479
variant="danger"
455-
/>
480+
>
481+
<MobileCaption
482+
slot="captions"
483+
words={words}
484+
currentTime={exploitTimeline.currentTime}
485+
showCaptions={exploitTimeline.showCaptions}
486+
/>
487+
</VideoControls>
456488

457489
<!-- Vulnerable Code -->
458490
<div class="vulnerable-code-section">
@@ -529,6 +561,13 @@
529561
margin-bottom: 1rem;
530562
}
531563
564+
@media (max-width: 1000px) {
565+
/* Add padding for sticky video controls at bottom */
566+
.animation-container {
567+
padding-bottom: 120px;
568+
}
569+
}
570+
532571
@media (max-width: 900px) {
533572
.exploit-visualization { grid-template-columns: 1fr; }
534573
}

‎src/lib/components/steps/FixStep.svelte‎

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44
import StepNavigation from '../StepNavigation.svelte';
55
import VideoControls from '../VideoControls.svelte';
66
import WordCaption from '../WordCaption.svelte';
7+
import MobileCaption from '../MobileCaption.svelte';
78
import { fixTimeline, getAnimationState, type StepTimeline } from '$lib/stores/timeline.svelte';
89
import { whisperToCaptions, extractFixKeyframeTriggers, getAudioDuration, getAllWords, type WhisperOutput, type WhisperWord } from '$lib/utils/whisper-parser';
910
import { comprehension, loadWhisperData } from '$lib/stores/comprehension.svelte';
1011
import { onMount, tick } from 'svelte';
12+
import { scrollToTarget, resetScrollTracking, type ScrollTarget } from '$lib/utils/autoScroll';
1113
1214
// Loading state for lazy loading
1315
let isLoading = $state(true);
1416
let loadError = $state<string | null>(null);
1517
18+
// Container ref for auto-scrolling on mobile
19+
let animationContainer = $state<HTMLElement | null>(null);
20+
1621
// Current whisper data - loaded lazily
1722
let whisper = $state<WhisperOutput | null>(null);
1823
let captions = $derived(whisper ? whisperToCaptions(whisper) : []);
@@ -177,6 +182,28 @@
177182
178183
// Derive animation state from currentTime - build keyframes inline to ensure reactivity
179184
let animState = $derived(getAnimationState(fixTimeline.currentTime, buildKeyframes(triggers), INITIAL_STATE));
185+
186+
// Derive the scroll target from animation state
187+
// FixStep doesn't have network animation, so we keep it simple
188+
let scrollTarget = $derived<ScrollTarget>(() => {
189+
if (animState.phase === 'remediation') {
190+
return 'explanation'; // Scroll to remediation cards
191+
}
192+
return 'browser'; // Default to code diff area
193+
});
194+
195+
// Auto-scroll on mobile when animation phase changes
196+
$effect(() => {
197+
const target = scrollTarget();
198+
if (!fixTimeline.playing || !animationContainer) return;
199+
scrollToTarget(animationContainer, target, { minIntervalMs: 1500 });
200+
});
201+
202+
// Reset scroll tracking when component mounts/unmounts
203+
onMount(() => {
204+
resetScrollTracking();
205+
return () => resetScrollTracking();
206+
});
180207
</script>
181208

182209
<StepSection step={4} variant="fix">
@@ -203,7 +230,7 @@
203230
</div>
204231
{/if}
205232

206-
<div class="animation-container" class:loading={isLoading}>
233+
<div class="animation-container" class:loading={isLoading} bind:this={animationContainer}>
207234
<div class="code-diff">
208235
<div class="diff-panel before-panel" class:highlight={animState.highlightVulnerable}>
209236
<div class="diff-header danger-header">
@@ -267,7 +294,14 @@
267294
onToggleCaptions={() => fixTimeline.toggleCaptions()}
268295
onPlaybackRateChange={(r) => fixTimeline.setPlaybackRate(r)}
269296
variant="success"
270-
/>
297+
>
298+
<MobileCaption
299+
slot="captions"
300+
words={words}
301+
currentTime={fixTimeline.currentTime}
302+
showCaptions={fixTimeline.showCaptions}
303+
/>
304+
</VideoControls>
271305

272306
<div class="remediation-section">
273307
<h3>How to Patch Your Application</h3>
@@ -320,6 +354,13 @@
320354
margin-bottom: 1.5rem;
321355
}
322356
357+
@media (max-width: 1000px) {
358+
/* Add padding for sticky video controls at bottom */
359+
.animation-container {
360+
padding-bottom: 120px;
361+
}
362+
}
363+
323364
@media (max-width: 900px) {
324365
.code-diff {
325366
grid-template-columns: 1fr;

‎src/lib/components/steps/LessonsStep.svelte‎

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
import StepHeader from '../StepHeader.svelte';
44
import VideoControls from '../VideoControls.svelte';
55
import WordCaption from '../WordCaption.svelte';
6+
import MobileCaption from '../MobileCaption.svelte';
67
import { lessonsTimeline, getAnimationState, type StepTimeline } from '$lib/stores/timeline.svelte';
78
import { whisperToCaptions, extractLessonsKeyframeTriggers, getAudioDuration, getAllWords, type WhisperOutput, type WhisperWord } from '$lib/utils/whisper-parser';
89
import { comprehension, loadWhisperData } from '$lib/stores/comprehension.svelte';
910
import { onMount, tick } from 'svelte';
11+
import { scrollToTarget, resetScrollTracking, type ScrollTarget } from '$lib/utils/autoScroll';
1012
1113
// Loading state for lazy loading
1214
let isLoading = $state(true);
1315
let loadError = $state<string | null>(null);
1416
17+
// Container ref for auto-scrolling on mobile
18+
let animationContainer = $state<HTMLElement | null>(null);
19+
1520
// Current whisper data - loaded lazily
1621
let whisper = $state<WhisperOutput | null>(null);
1722
let captions = $derived(whisper ? whisperToCaptions(whisper) : []);
@@ -140,6 +145,28 @@
140145
// Derive animation state from currentTime - build keyframes inline to ensure reactivity
141146
let animState = $derived(getAnimationState(lessonsTimeline.currentTime, buildKeyframes(triggers), INITIAL_STATE));
142147
148+
// Derive the scroll target from animation state
149+
// LessonsStep scrolls to cards as they become active, then to resources section
150+
let scrollTarget = $derived<ScrollTarget>(() => {
151+
if (animState.showResources) {
152+
return 'explanation'; // Scroll to resources at bottom
153+
}
154+
return 'browser'; // Default to lessons cards area
155+
});
156+
157+
// Auto-scroll on mobile when animation phase changes
158+
$effect(() => {
159+
const target = scrollTarget();
160+
if (!lessonsTimeline.playing || !animationContainer) return;
161+
scrollToTarget(animationContainer, target, { minIntervalMs: 1500 });
162+
});
163+
164+
// Reset scroll tracking when component mounts/unmounts
165+
onMount(() => {
166+
resetScrollTracking();
167+
return () => resetScrollTracking();
168+
});
169+
143170
// Helper to check if card is completed
144171
function isCompleted(cardNum: number): boolean {
145172
return animState.completedCards.includes(cardNum);
@@ -166,7 +193,7 @@
166193
</div>
167194
{/if}
168195

169-
<div class="animation-container" class:loading={isLoading}>
196+
<div class="animation-container" class:loading={isLoading} bind:this={animationContainer}>
170197
<div class="lessons-grid">
171198
<div class="lesson-card" class:active={animState.activeCard === 1} class:completed={isCompleted(1)}>
172199
<div class="lesson-icon"><i class="fa-solid fa-bullseye"></i></div>
@@ -223,7 +250,14 @@
223250
onToggleMute={() => lessonsTimeline.toggleMute()}
224251
onToggleCaptions={() => lessonsTimeline.toggleCaptions()}
225252
onPlaybackRateChange={(r) => lessonsTimeline.setPlaybackRate(r)}
226-
/>
253+
>
254+
<MobileCaption
255+
slot="captions"
256+
words={words}
257+
currentTime={lessonsTimeline.currentTime}
258+
showCaptions={lessonsTimeline.showCaptions}
259+
/>
260+
</VideoControls>
227261

228262
<div class="final-section" class:visible={animState.showQuote}>
229263
<blockquote>
@@ -276,6 +310,13 @@
276310
margin-bottom: 1.5rem;
277311
}
278312
313+
@media (max-width: 1000px) {
314+
/* Add padding for sticky video controls at bottom */
315+
.animation-container {
316+
padding-bottom: 120px;
317+
}
318+
}
319+
279320
@media (max-width: 700px) {
280321
.lessons-grid {
281322
grid-template-columns: 1fr;

0 commit comments

Comments
 (0)