apply viewport resize and input event changes

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent 499d84fc70
commit f7e4a90751
5 changed files with 29 additions and 8 deletions

View File

@@ -1,10 +1,10 @@
const FRAME_MS = 16;
function later(cb: () => void, delayMs: number) {
function later(cb: () => void, delayMs: number, speed = 1) {
const now = performance.now();
function check(step: number) {
if (step - now > delayMs - FRAME_MS) {
if (step - now > delayMs / speed - FRAME_MS) {
cb();
} else {
requestAnimationFrame(check);