本文整理匯總了TypeScript中raf.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: wrapperRaf
// Support call raf with delay specified frame
export default function wrapperRaf(callback: () => void, delayFrames: number = 1): number {
const myId: number = id++;
let restFrames: number = delayFrames;
function internalCallback() {
restFrames -= 1;
if (restFrames <= 0) {
callback();
delete ids[myId];
} else {
ids[myId] = raf(internalCallback);
}
}
ids[myId] = raf(internalCallback);
return myId;
}
示例2: processFrameCallbacks
function processFrameCallbacks(time: number) {
if (paused) {
requestAnimationFrame(processFrameCallbacks);
return;
}
setTime(time);
const currentCallbacks = popAll(frameCallbacks);
currentCallbacks.forEach(callback => callback(time));
requestAnimationFrame(processFrameCallbacks);
}
示例3: internalCallback
function internalCallback() {
restFrames -= 1;
if (restFrames <= 0) {
callback();
delete ids[myId];
} else {
ids[myId] = raf(internalCallback);
}
}
示例4: runRealtime
function runRealtime(
scheduler: any,
frameCallbacks: any,
currentTime: () => number,
setTime: (t: number) => void,
) {
let paused = false;
const pause = () => (paused = true);
const resume = (time: number) => {
setTime(time);
paused = false;
};
function processFrameCallbacks(time: number) {
if (paused) {
requestAnimationFrame(processFrameCallbacks);
return;
}
setTime(time);
const currentCallbacks = popAll(frameCallbacks);
currentCallbacks.forEach(callback => callback(time));
requestAnimationFrame(processFrameCallbacks);
}
requestAnimationFrame(processFrameCallbacks);
function processEvent() {
if (paused) {
return;
}
const time = now();
setTime(time);
if (scheduler.isEmpty()) {
return;
}
let nextEventTime = scheduler.peek().time;
while (nextEventTime < time) {
const eventToProcess = scheduler.shiftNextEntry();
if (!eventToProcess.cancelled) {
if (eventToProcess.f) {
eventToProcess.f(eventToProcess, time, scheduler.add, currentTime);
}
if (eventToProcess.type === 'next') {
eventToProcess.stream.shamefullySendNext(eventToProcess.value);
}
if (eventToProcess.type === 'complete') {
eventToProcess.stream.shamefullySendComplete();
}
}
nextEventTime = (scheduler.peek() && scheduler.peek().time) || Infinity;
}
}
setInterval(processEvent, 10);
return {pause, resume};
}