Responsive Adaptive

dylantarre/animation-principles/skills/10-by-time-scale/responsive-adaptive

作者 dylantarre83597134ba8f无许可证99 个星标收录于 2026年10月8日更新于 2026年10月8日仓库9个月前更新

Use when building context-dependent animations - duration that changes based on device, distance, user preference, or interaction context

AI 生成的概览

指导自适应动画时长,根据设备、距离、用户偏好和交互情境调整持续时间。

功能
该技能为构建依赖情境的动画时长提供指导,涵盖自适应应用的迪士尼动画原则,以及基于距离、设备和用户偏好的时长策略。它给出 CSS 与 JavaScript 示例、情境规则表,以及配合媒体查询的令牌化实现模式。产出的是指导性说明,而非生成的文件或代码成品。
适用场景
适用于定义需要随设备能力、移动距离、减少动态效果偏好或交互类型而变化的动画或过渡时长。适合单一固定时长在不同情境下都不合适的前端工作。
运行要求
除智能体外无需其他条件;仅为说明性内容,不附带脚本。

Responsive & Adaptive Timing

Responsive timing adapts duration to context: device capability, travel distance, user preferences, and interaction type. One duration doesn't fit all situations.

Disney Principles for Adaptive Motion

Context-Aware Application

Squash & Stretch: Scale with device - more subtle on mobile (less screen real estate for deformation).

Anticipation: Shorter on touch devices - touch users expect faster response than mouse users.

Staging: Adapt to viewport - smaller screens need more focused staging, less simultaneous motion.

Straight Ahead/Pose to Pose: Same approach, scaled duration - poses stay, timing adjusts.

Follow Through: Proportional to distance - longer travel = more follow-through time.

Slow In/Slow Out: Adjust curve intensity - faster animations need sharper easing.

Arcs: Same paths, different speeds - arc shape remains, traversal time changes.

Secondary Action: Reduce on mobile - fewer simultaneous animations for performance.

Timing: THE adaptive variable - timing changes, principles stay.

Exaggeration: Less on smaller screens - proportional to viewport/element size.

Solid Drawing: Performance-aware - reduce 3D transforms on weaker devices.

Appeal: Context-appropriate - what feels right on desktop may feel slow on mobile.

Adaptive Strategies

Distance-Based Duration

css
/* Base duration for reference distance */--base-duration: 300ms;--base-distance: 100px;
/* Duration scales with distance *//* 50px travel = 200ms, 200px travel = 450ms */
javascript
function getDuration(distance) {  const baseDuration = 300;  const baseDistance = 100;  return Math.min(600, baseDuration * Math.sqrt(distance / baseDistance));}

Device-Based Duration

css
/* Desktop - full duration */.transition { transition-duration: 400ms; }
/* Tablet - slightly faster */@media (max-width: 1024px) {  .transition { transition-duration: 350ms; }}
/* Mobile - faster for perceived responsiveness */@media (max-width: 768px) {  .transition { transition-duration: 250ms; }}

Preference-Based Duration

css
/* Respect reduced motion preference */@media (prefers-reduced-motion: reduce) {  .transition {    transition-duration: 0.01ms !important;    animation-duration: 0.01ms !important;  }}
/* Reduce motion, don't eliminate */@media (prefers-reduced-motion: reduce) {  .transition {    transition-duration: 100ms;    transform: none; /* Only opacity fades */  }}

Context Rules

ContextDuration Adjustment
Touch device-25% from desktop
Small viewport-20% from desktop
Large travel distance+50% base
Small travel distance-30% base
User prefers reducedInstant or minimal
Low power mode-50% or disabled
High-frequency actionUse minimum duration
First-time viewFull duration
Repeat interactionReduced duration

Implementation Pattern

css
:root {  --duration-instant: 50ms;  --duration-fast: 150ms;  --duration-normal: 300ms;  --duration-slow: 500ms;}
@media (max-width: 768px) {  :root {    --duration-fast: 100ms;    --duration-normal: 200ms;    --duration-slow: 350ms;  }}
@media (prefers-reduced-motion: reduce) {  :root {    --duration-instant: 0ms;    --duration-fast: 0ms;    --duration-normal: 100ms;    --duration-slow: 150ms;  }}

Key Insight

Great animation adapts like typography adapts - what works at one size/context may not work at another. Build systems, not fixed values. Test across contexts. Duration is a variable, not a constant.

来源与署名

来源:dylantarre/animation-principles位于skills/10-by-time-scale/responsive-adaptive提交8359713

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架