图像与设计
用 Motion One…
在基于 Motion One 的前端项目中,落地迪士尼十二动画原则,并实现交错、滚动联动和进入视口动画。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 60/100 ×0.15
适用场景
用 Motion One 实现迪士尼十二特定
解决思路
- 1. Squash and Stretch:先 import { animate } from 'motion';,再用 animate('.ball', { scaleX: [1, 1.2, 1], scaleY: [1, 0.8, 1] }, { duration: 0.3, easing: 'ease-in-out' }); 通过相反方向的 X/Y 缩放实现挤压拉伸。
- 2. Anticipation:先 import { timeline } from 'motion';,再用 timeline([ ['.character', { y: 10, scaleY: 0.9 }, { duration: 0.2 }], ['.character', { y: -200 }, { duration: 0.4, easing: 'ease-out' }] ]); 先做反向预备动作,再做主要动作。
- 3. Staging:用 animate('.background', { filter: 'blur(3px)', opacity: 0.6 }); animate('.hero', { scale: 1.1 }); 模糊/淡化背景并放大主体,以突出焦点。
- 4. Straight Ahead / Pose to Pose:用 animate('.element', { x: [0, 100, 200, 300], y: [0, -50, 0, -30] }, { duration: 1 }); 通过关键帧序列控制连续动作或姿势到姿势。
- 5. Follow Through and Overlapping Action:用 timeline([ ['.body', { x: 200 }, { duration: 0.5 }], ['.hair', { x: 200 }, { duration: 0.5, at: '-0.45' }], ['.cape', { x: 200 }, { duration: 0.6, at: '-0.5' }] ]); 让身体、头发、披风等部件错开跟随。
- 6. Slow In and Slow Out:用 animate('.element', { x: 300 }, { duration: 0.6, easing: [0.42, 0, 0.58, 1] }); 也可用 'ease-in'、'ease-out'、'ease-in-out',或用 import { spring } from 'motion'; 后调用 spring({ stiffness: 100, damping: 15 }) 的弹簧缓动。
- 7. Arc:用 animate('.ball', { x: [0, 100, 200], y: [0, -100, 0] }, { duration: 1, easing: 'ease-in-out' }); 或用 offset path:animate('.element', { offsetDistance: ['0%', '100%'] }, { duration: 1 }); 并在 CSS 中设置 offset-path: path('M0,100 Q100,0 200,100');
- 8. Secondary Action:先 const button = document.querySelector('.button');,再 button.addEventListener('mouseenter', () => { animate(button, { scale: 1.05 }, { duration: 0.2 }); animate('.icon', { rotate: 15 }, { duration: 0.15 }); }); 添加次要动作。
- 9. Timing:快照用 animate('.fast', { x: 100 }, { duration: 0.15 }); 弹簧物理用 import { spring } from 'motion'; 后 animate('.spring', { x: 100 }, { easing: spring({ stiffness: 300, damping: 20 }) }); 慢速戏剧化用 animate('.slow', { x: 100 }, { duration: 0.8, easing: 'ease-out' });
- 10. Exaggeration:先 import { spring } from 'motion';,再用 animate('.element', { scale: 1.5, rotate: 720 }, { easing: spring({ stiffness: 200, damping: 10 }) }); 通过弹簧过冲实现夸张。
- 11. Solid Drawing:用 animate('.box', { rotateX: 45, rotateY: 30 }, { duration: 0.5 }); 并在 CSS 中设置 perspective: 1000px; 来增强立体感。
- 12. Appeal:用 animate('.card', { scale: 1.02, boxShadow: '0 20px 40px rgba(0,0,0,0.2)' }, { duration: 0.3, easing: 'ease-out' }); 通过轻微缩放和阴影提升吸引力。
- Stagger Animation:先 import { stagger } from 'motion';,再用 animate('.item', { opacity: [0, 1], y: [20, 0] }, { delay: stagger(0.1) }); 为多个元素制造交错延迟。
- Scroll Animations:先 import { scroll, animate } from 'motion';,再用 scroll(animate('.parallax', { y: [0, 100] }), { target: document.querySelector('.container') }); 实现滚动联动动画。
- In-View Animations:先 import { inView } from 'motion';,再用 inView('.section', ({ target }) => { animate(target, { opacity: 1, y: 0 }, { duration: 0.5 }); }); 在元素进入视口时触发动画。
- Key Motion One Features - animate():用 animate() 创建单个动画。
- Key Motion One Features - timeline():用 timeline() 创建带 at 定位的序列动画。
- Key Motion One Features - stagger():用 stagger() 设置偏移延迟。
- Key Motion One Features - spring():用 spring() 设置基于物理的缓动。
- Key Motion One Features - scroll():用 scroll() 创建滚动联动动画。
- Key Motion One Features - inView():用 inView() 包装 Intersection Observer。
- Key Motion One Features - Web Animations API:使用基于 Web Animations API 的 Motion One 以获得硬件加速。
- Key Motion One Features - Bundle size:在需要小体积动画库时使用 Motion One(约 3kb)。
适用边界 · 注意事项
- 未引入 Motion One 或目标环境不支持 Web Animations API 时,不要用本技能。
- 需要复杂 3D/Canvas/WebGL、游戏循环或逐帧精确控制时,Motion One 的 WAAPI 包装不一定合适。
- 只需极少量 CSS transition 且不想增加依赖时,不必引入 Motion One。