implementation-debugging

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Implementation Debugging

动画实现调试

Debug animation issues using Disney's principles as diagnostic framework.
使用迪士尼动画原则作为诊断框架来调试动画问题。

Problem Indicators

问题表现

  • Animation doesn't play at all
  • Animation plays but looks wrong
  • Works in dev, broken in production
  • Inconsistent across browsers
  • Animation triggers at wrong time
  • Flickering or visual glitches
  • 动画完全不播放
  • 动画播放但效果异常
  • 开发环境正常,生产环境失效
  • 在不同浏览器中表现不一致
  • 动画触发时机错误
  • 出现闪烁或视觉故障

Diagnosis by Principle

基于动画原则的诊断

Timing

时间节奏(Timing)

Issue: Animation timing is off Debug: Check duration values. Verify units (ms vs s). Check if CSS transition is being overridden. Inspect computed styles.
问题:动画时间节奏异常 调试方法:检查时长数值,验证单位(ms 或 s),确认CSS过渡是否被覆盖,检查计算后的样式。

Straight Ahead vs Pose-to-Pose

逐帧动画与关键帧动画(Straight Ahead vs Pose-to-Pose)

Issue: Keyframes not hitting Debug: Verify all keyframe percentages. Check for typos in property names. Ensure values are animatable.
问题:关键帧未生效 调试方法:验证所有关键帧百分比,检查属性名称是否有拼写错误,确保属性支持动画。

Staging

舞台呈现(Staging)

Issue: Animation hidden or clipped Debug: Check z-index, overflow, opacity. Verify element is in viewport. Check for
visibility: hidden
.
问题:动画被隐藏或裁剪 调试方法:检查z-index、overflow、opacity属性,确认元素在视口中,检查是否设置了
visibility: hidden

Solid Drawing

立体造型(Solid Drawing)

Issue: Visual glitches during animation Debug: Look for subpixel rendering issues. Add
transform: translateZ(0)
for GPU layer. Check for layout thrashing.
问题:动画过程中出现视觉故障 调试方法:检查是否存在子像素渲染问题,添加
transform: translateZ(0)
启用GPU层,检查是否存在布局抖动。

Follow Through

跟随动作(Follow Through)

Issue: Animation ends abruptly or wrong state Debug: Check
animation-fill-mode
. Verify end state matches CSS. Check for competing animations.
问题:动画突然结束或最终状态错误 调试方法:检查
animation-fill-mode
属性,验证最终状态是否与CSS设置一致,检查是否存在冲突的动画。

Common Bugs

常见Bug

SymptomLikely CauseFix
No animationProperty not animatableUse transform instead of changing property directly
Flicker at startNo initial stateSet initial values explicitly
Wrong end stateFill modeAdd
forwards
to animation
Choppy motionLayout thrashingAnimate only transform/opacity
Works once onlyAnimation not resetRemove and re-add class, or use JS
症状可能原因修复方法
无动画效果属性不支持动画使用transform替代直接修改属性
启动时闪烁未设置初始状态显式设置初始值
最终状态错误填充模式问题为动画添加
forwards
运动卡顿布局抖动仅对transform/opacity属性执行动画
仅能生效一次动画未重置移除并重新添加类名,或使用JS实现重置

Quick Fixes

快速修复方案

  1. Check DevTools Animation panel - See timeline
  2. Verify animatable properties - Not all CSS animates
  3. Add
    animation-fill-mode: forwards
    - Keep end state
  4. Force GPU layer -
    will-change: transform
  5. Check for
    !important
    - May override animation
  1. 检查DevTools动画面板 - 查看时间线
  2. 验证可动画属性 - 并非所有CSS属性都支持动画
  3. 添加
    animation-fill-mode: forwards
    - 保留最终状态
  4. 强制启用GPU层 - 使用
    will-change: transform
  5. 检查
    !important
    声明
    - 该声明可能覆盖动画

Troubleshooting Checklist

故障排查清单

  • Is animation class/trigger being applied? (DevTools Elements)
  • Are properties animatable? (
    display
    is not,
    opacity
    is)
  • Check computed styles for overrides
  • Is element visible? (opacity, visibility, display, z-index)
  • Any JavaScript errors blocking execution?
  • Check Animation panel in DevTools
  • Test in incognito (no extensions)
  • Compare working vs broken environment
  • 动画类/触发器是否已应用?(DevTools元素面板)
  • 属性是否支持动画?(
    display
    不支持,
    opacity
    支持)
  • 检查计算后的样式是否被覆盖
  • 元素是否可见?(检查opacity、visibility、display、z-index)
  • 是否有JavaScript错误阻止执行?
  • 检查DevTools中的动画面板
  • 在无痕模式下测试(无扩展干扰)
  • 对比正常与异常环境的差异

Code Pattern

代码示例

js
// Debug: Log animation events
element.addEventListener('animationstart', (e) => {
  console.log('Animation started:', e.animationName);
});

element.addEventListener('animationend', (e) => {
  console.log('Animation ended:', e.animationName);
});

// Debug: Check computed animation
const styles = getComputedStyle(element);
console.log('Animation:', styles.animation);
console.log('Transition:', styles.transition);

// Reset animation
element.classList.remove('animate');
void element.offsetWidth; // Trigger reflow
element.classList.add('animate');
js
// Debug: Log animation events
element.addEventListener('animationstart', (e) => {
  console.log('Animation started:', e.animationName);
});

element.addEventListener('animationend', (e) => {
  console.log('Animation ended:', e.animationName);
});

// Debug: Check computed animation
const styles = getComputedStyle(element);
console.log('Animation:', styles.animation);
console.log('Transition:', styles.transition);

// Reset animation
element.classList.remove('animate');
void element.offsetWidth; // Trigger reflow
element.classList.add('animate');

DevTools Tips

DevTools使用技巧

  1. Elements > Styles: Check computed animation values
  2. Performance tab: Record and analyze frames
  3. Animations panel: Slow down, replay, inspect
  4. Console: Log animation events
  1. 元素 > 样式:检查计算后的动画值
  2. 性能面板:录制并分析帧情况
  3. 动画面板:慢放、重放、检查动画细节
  4. 控制台:打印动画事件