.getVelocity
.getVelocity( ) : Number
返回当前平滑滚动的速度,单位为像素/秒。
细节
返回平滑滚动的当前速度,单位为像素每秒。例如:
ScrollSmoother.create({
onUpdate: (self) => console.log("velocity:", self.getVelocity()),
});
另一种写法是:
let smoother = ScrollSmoother.create({...});
button.addEventListener("click", () => {
console.log("velocity:", smoother.getVelocity());
});