跳到正文
网页珍奇柜Web Curio

滚动列表的 3D 入场效果

stroll.js,Hakim El Hattab,2012 年

正在布展…

原作直展:这是 Hakim El Hattab 的原始作品,按 MIT(附带的 Lato 字体为 OFL) 许可证收录(版本 72f87f6)。原作演示页展出;去掉了 Facebook、Twitter 按钮和 GitHub 角标,字体换成随附副本。滚动每一列列表,看不同的滚动特效。 许可证全文 · 收录说明

它是怎么做的

  1. 第 1 步监听列表容器滚动,判断每个 li 是否处于视口之外的上方或下方
  2. 第 2 步给视口外的条目加上 past/future 类
  3. 第 3 步CSS 为每种效果定义 past/future 状态下的 3D 变换(rotateX、translateZ 等)
  4. 第 4 步条目进入视口时移除类名,由 transition 动画回到原位

复刻配方

一段技术配方,可以直接交给 AI 编程助手,也可以自己照着写。想指定技术栈、位置和性能预算,就把它加入实现方案。

Give each list item a CSS transition on transform and opacity and set perspective on the list. On scroll (throttled with requestAnimationFrame), compare each item's offset with the visible range and toggle a 'past' class for items above and a 'future' class for items below. Define per-effect CSS for those classes, for example rotateX(-90deg) with transform-origin at the top for a flip, or translateZ and rotateY for a helix. Items animate back to identity when they enter view.

档案

交互

能不能拿来用

原作以 MIT 许可开源:可以阅读源码学习,按许可证条款使用;在自己的项目里引用时保留原作者署名。

性能开销

视觉强度

实现难度

尺度为策展判断(1 到 5),用于比较和推荐。

核实记录:Opened http://lab.hakim.se/scroll-effects (200, title 'stroll.js - CSS3 Scroll Effects'); repo hakimel/stroll.js exists, licence MIT via GitHub API.