小程序
小游戏
企业微信
微信支付
扫描小程序码分享
小游戏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
{
谢谢回复这么多,长见识了,这是官方自己增加的吧
内容中可能包含密钥、AppSecret等私密参数,泄漏会有安全风险,请检查内容并确认。
还有第三个参数呢,你知不知道,下面是部分源码
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
}
}
谢谢回复这么多,长见识了,这是官方自己增加的吧