This commit is contained in:
2025-08-21 11:23:54 +08:00
commit abf7f3c799
530 changed files with 60239 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
// @ts-nocheck
// #ifdef UNI-APP-X && APP
// export * from './uvue'
export { raf, doubleRaf, cancelRaf } from './uvue'
// #endif
// #ifndef UNI-APP-X && APP
// export * from './vue'
export { raf, doubleRaf, cancelRaf } from './vue'
// #endif

View File

@@ -0,0 +1,48 @@
// @ts-nocheck
// 是否支持被动事件监听
export const supportsPassive = true;
// #ifdef uniVersion < 4.25
// 请求动画帧
export function raf(fn: TimerCallback): number {
return setTimeout(fn, 1000 / 60);
}
// 取消动画帧
export function cancelRaf(id: number) {
clearTimeout(id);
}
// 双倍动画帧
export function doubleRaf(fn: TimerCallback): void {
raf(():number => raf(fn)); // 在下一帧回调中再次请求动画帧,实现双倍动画帧效果
}
// #endif
// #ifdef uniVersion >= 4.25
// 请求动画帧
export function raf(fn: UniAnimationFrameCallback): number
export function raf(fn: UniAnimationFrameCallbackWithNoArgument): number
export function raf(fn: any): number {
if(typeof fn == 'UniAnimationFrameCallback') {
return requestAnimationFrame(fn as UniAnimationFrameCallback);
} else {
return requestAnimationFrame(fn as UniAnimationFrameCallbackWithNoArgument);
}
}
// 取消动画帧
export function cancelRaf(id: number) {
cancelAnimationFrame(id);
}
// 双倍动画帧
export function doubleRaf(fn: UniAnimationFrameCallback): void
export function doubleRaf(fn: UniAnimationFrameCallbackWithNoArgument): void
export function doubleRaf(fn: any): void {
raf(():number => raf(fn)); // 在下一帧回调中再次请求动画帧,实现双倍动画帧效果
}
// #endif

View File

@@ -0,0 +1,32 @@
// @ts-nocheck
type Callback = () => void//Function
// 是否支持被动事件监听
export const supportsPassive = true;
// 请求动画帧
export function raf(fn : Callback) : number {
// #ifndef WEB
return setTimeout(fn, 1000 / 60); // 请求动画帧
// #endif
// #ifdef WEB
return requestAnimationFrame(fn); // 请求动画帧
// #endif
}
// 取消动画帧
export function cancelRaf(id : number) {
// 如果是在浏览器环境下,使用 cancelAnimationFrame 方法
// #ifdef WEB
cancelAnimationFrame(id); // 取消动画帧
// #endif
// #ifndef WEB
clearTimeout(id); // 取消动画帧
// #endif
}
// 双倍动画帧
export function doubleRaf(fn : Callback) : void {
raf(() => {
raf(fn)
}); // 在下一帧回调中再次请求动画帧,实现双倍动画帧效果
}