本文整理汇总了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};
}