电梯式回到顶部
Elevator.js,Tim Holman,2015 年

正在布展…
它是怎么做的
- 第 1 步根据滚动距离计算一个较长的动画时长。
- 第 2 步用 easeInOut 缓动逐帧设置 scrollTop。
- 第 3 步开始时播放循环背景音乐,结束时停掉并播放到达音效。
- 第 4 步用户中途滚动会打断动画。
复刻配方
一段技术配方,可以直接交给 AI 编程助手,也可以自己照着写。想指定技术栈、位置和性能预算,就把它加入实现方案。
On button click, record the current scroll position and compute a duration proportional to distance (clamped). Start a looping audio element with your own royalty-free track, then animate window.scrollTo each frame with an ease-in-out curve. Cancel on wheel or touchstart. When the animation completes, stop the loop and play a short chime synthesized with WebAudio (two sine oscillators with a quick decay envelope) so no audio license is needed.
档案
能不能拿来用
原作以 MIT (stated in README; demo audio is separately licensed) 许可开源:可以阅读源码学习,按许可证条款使用;在自己的项目里引用时保留原作者署名。
性能开销
视觉强度
实现难度
尺度为策展判断(1 到 5),用于比较和推荐。
核实记录:Live demo loads (HTTP 200, title 'Elevator.js'); README states 'covered by the MIT License' and notes demo audio was bought from Pond5.


