You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: optimize 3D cube with visibility observer and remove CPU-intensive sparkler
- Remove sparkler animation feature (CPU intensive)
- Delete src/sparkler-animator.ts and tests
- Remove sparkler imports and dependencies from main.ts and magic-phase-animator.ts
- Update story requirements to remove sparkler acceptance criteria
- Add visibility-based pause/resume for 3D cube
- Implement IntersectionObserver to pause animation when off-screen
- Resume animation automatically when cube enters viewport
- Works for both WebGL and fallback modes
- Add proper cleanup in destroy method
- Benefits:
- Reduced CPU/GPU usage when cube not visible
- Better battery life on mobile devices
- Improved overall performance
- No user-visible changes to experience
Closes: Performance optimization requirements
Tests: All 361 tests passing
-**REQ-ENERGETIC-ENTRANCE**: Segment 2 flies in with momentum overshoot, then snaps sharply into final position
50
-
-**REQ-ETHEREAL-FEEL**: Dreamy fog-emergence effect for Segment 1; energetic slide-in for Segment 2matic (0.92-1.08)
51
45
-**REQ-ETHEREAL-FEEL**: Dreamy fog-emergence effect for Segment 1; energetic slide-in for Segment 2
52
46
53
47
### Specific Animations
@@ -58,11 +52,6 @@ So that I feel the magic and wonder of early AI coding, as a user scrolling thro
58
52
- Lower amplitude (4px) for "REMEMBER WHEN", higher (8px) for "AI coding..." headline
59
53
- Horizontal bobbing component (30% of vertical) for natural motion
60
54
- Bobbing amplitude fades in/out with element visibility to prevent jumps
61
-
- Canvas-based sparkler particles sweep across "magic?" word triggered at 20% scroll progress
62
-
- Sparkle sweep expands left-to-right (0-50% of animation), then contracts (50-100%)
63
-
- Text reveals in sync with sparkle expansion using progressive clip-path
64
-
- "Magic?" appears white during sparkles, fades to teal over 0.5s after sweep completes
65
-
- Sparkler canvas fades in (5-20%), stays visible (20-45%), fades out (45-60%)
66
55
- Individual timing per element via data-reveal-start/end attributes
67
56
68
57
-**REQ-SEGMENT-2**: "When shipping features was fast and exciting?"
@@ -77,15 +66,6 @@ So that I feel the magic and wonder of early AI coding, as a user scrolling thro
77
66
78
67
### Technical Implementation
79
68
80
-
-**REQ-CSS-TRANSFORMS**: Use hardware-accelerated CSS transforms (translateX, translateY, scale, rotate)
81
-
-**REQ-SCROLL-INTERPOLATION**: Animation progress based on scroll position within per-element data-reveal-start/end ranges
82
-
-**REQ-CANVAS-PARTICLES**: Hardware-accelerated canvas rendering for sparkler particle effects
83
-
-**REQ-CLIP-PATH-REVEAL**: Progressive text reveal using CSS clip-path synchronized with particle animation
84
-
-**REQ-SCROLL-TRIGGERED**: Sparkle animation triggers on scroll threshold crossing, not continuously scrubbed
85
-
-**REQ-SMART-RETRIGGER**: Sparkle only retriggers when text fully fades out (opacity = 0), not on partial scroll-ups
86
-
-**REQ-PERFORMANCE-OPTIMIZED**: Continuous requestAnimationFrame loop for bobbing; scroll-based for reveal/transitions
87
-
-**REQ-SEQUENTIAL-ENFORCEMENT**: Segment 2 timing set to start after Segment 1 ends (no overlap)
88
-
89
69
-**REQ-CSS-TRANSFORMS**: Use hardware-accelerated CSS transforms (translateX, translateY, scale, rotate)
90
70
-**REQ-SCROLL-INTERPOLATION**: Animation progress based on scroll position within per-element data-reveal-start/end ranges
91
71
-**REQ-MAGIC-WORD-EFFECTS**: Special effects for words with .magic-word and .speed-word classes
@@ -238,20 +218,7 @@ class MagicPhaseAnimator {
238
218
### Success Criteria
239
219
240
220
- Each Segment 1 element bobs independently like different boats on water
241
-
- Sparkler particles sweep dramatically across "magic?" word when scrolling into view
242
-
- Text reveals progressively in sync with sparkle expansion
243
-
- Word appears white during animation, then smoothly transitions to teal
244
-
- Sparkle canvas fades in/out gracefully with overall narrative timing
245
-
- Scrolling up partially preserves animation state without retriggering
246
-
- Only fully scrolling out (opacity = 0) resets for fresh retrigger
247
-
- Smooth 60fps performance on all devices
248
-
- Animations respect scroll direction (bidirectional)
249
-
- Foundation ready for other act animations
250
-
251
-
This story establishes the cinematic animation system with sophisticated particle effects and creates the magical emotional tone for the narrative journey.
252
-
253
221
- Segments float gently with dreamy motion
254
-
- Magic words have warm, ethereal glow effects
255
222
- Animations feel magical and wonder-filled
256
223
- Smooth 60fps performance on all devices
257
224
- Animations respect scroll direction (bidirectional)
0 commit comments