偵測
Callbacks + progress
獨立 ScrollTrigger.create(),用 onUpdate 讀 progress / direction / velocity。
導讀
不綁 tween,把 ScrollTrigger 當感測器:讀 progress / direction / isActive / velocity 自己更新 UI。
- 看什麼
- 右下 HUD 與中間進度條;進出區間時 isActive 翻轉。
- 怎麼試
- 改 start / end,觀察 active 區間何時開關、progress 如何 0→1。
Skill 對應:ScrollTrigger.create, onUpdate, onToggle
- 不必綁 tween:
ScrollTrigger.create({...})就能拿 progress - 常用 callback:onEnter / onLeave / onEnterBack / onLeaveBack / onUpdate / onToggle
- 改 start / end 後看右下 HUD 的 progress / isActive 何時翻轉
ScrollTrigger.create({
trigger: "#zone",
start: "top center",
end: "bottom center",
onUpdate: (self) => {
console.log(self.progress, self.direction, self.getVelocity());
}
});Active Zone
當此區的 top 過視窗 center,到 bottom 過 center 為止為 active
- progress
- 0.000
- direction
- 1
- isActive
- false
- velocity
- 0