Investigating and Refactoring Center Offset in Theme Toggle Ripple Animation Based on View Transitions
TechnologyAI summary: Developer sin encountered a severe coordinate offset bug in a theme toggle button using the View Transitions API and WAAPI, where the ripple effect's center didn't align with the click point. Sin disproved initial hypotheses by showing the official NuxtUI template had the same bug and that a pure CSS control button worked perfectly. The root cause was identified as a Chromium rendering issue where WAAPI animations on snapshot pseudo-elements don't correctly account for device pixel ratio (DPR) scaling in modern versions, unlike CSS variables which are handled by the style engine. The solution was to refactor the component to use pure CSS with CSS variables for the animation, ensuring 0-pixel deviation. The article also discusses future View Transitions Level 2 'types' feature and reflects on the collaborative debugging process, emphasizing the importance of challenging authoritative templates and using control experiments.