小程序
小游戏
企业微信
微信支付
扫描小程序码分享
小游戏demorequestAnimationFrame传递了俩个参数,这是怎么回事,有知道的大佬说下呗
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
还有第三个参数呢,你知不知道,下面是部分源码
var
documentCreateElement = document.createElement.bind(document)
requestAnimationFrame = window.requestAnimationFrame.bind(window)
cancelAnimationFrame = window.cancelAnimationFrame.bind(window)
_fpsInterval, RAFIdMap = {}, cid = 0
wxRequestAnimationFrame = (cb, id, last) => {
if
(!_fpsInterval)
return
requestAnimationFrame(cb)
(!id) {
id = cid++
}
(!last) {
last = +
new
Date()
nativeId = requestAnimationFrame(wxRequestAnimationFrame.bind(
this
, cb, id, last))
RAFIdMap[id] = nativeId
id
now = +
(now - last >= _fpsInterval) {
last = now - (last % _fpsInterval)
delete
RAFIdMap[id]
cb()
else
{
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
谢谢回复这么多,长见识了,这是官方自己增加的吧
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
还有第三个参数呢,你知不知道,下面是部分源码
var
documentCreateElement = document.createElement.bind(document)
var
requestAnimationFrame = window.requestAnimationFrame.bind(window)
var
cancelAnimationFrame = window.cancelAnimationFrame.bind(window)
var
_fpsInterval, RAFIdMap = {}, cid = 0
var
wxRequestAnimationFrame = (cb, id, last) => {
if
(!_fpsInterval)
return
requestAnimationFrame(cb)
if
(!id) {
id = cid++
}
if
(!last) {
last = +
new
Date()
var
nativeId = requestAnimationFrame(wxRequestAnimationFrame.bind(
this
, cb, id, last))
RAFIdMap[id] = nativeId
return
id
}
var
now = +
new
Date()
if
(now - last >= _fpsInterval) {
last = now - (last % _fpsInterval)
delete
RAFIdMap[id]
cb()
}
else
{
var
nativeId = requestAnimationFrame(wxRequestAnimationFrame.bind(
this
, cb, id, last))
RAFIdMap[id] = nativeId
return
id
}
}
谢谢回复这么多,长见识了,这是官方自己增加的吧