ustbhuangyi / better-scroll

:scroll: inspired by iscroll, and it supports more features and has a better scroll perfermance
https://better-scroll.github.io/docs/en-US/
MIT License
16.45k stars 2.61k forks source link

raf.js 中 setTimeout 100 / 60 问题?网上资料都是 16.7 = 1000 / 60, 即每秒60帧,IScroll 也是这样。 #153

Closed proc07 closed 7 years ago

proc07 commented 7 years ago

const DEFAULT_INTERVAL = 100 / 60

export const requestAnimationFrame = (() => { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || // if all else fails, use setTimeout function (callback) { return window.setTimeout(callback, (callback.interval || DEFAULT_INTERVAL) / 2) // make interval as precise as possible. } })()

ustbhuangyi commented 7 years ago

其实并没有影响,即使你写 setTimeout(0),也会至少在一个 Tick(约为 17ms)后才会执行回调