/
ai_sampletext
/
DiplomWork
Обзор
Документация
Войти
/
ai_sampletext
/
DiplomWork
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
node_modules/react-smooth/src/setRafTimeout.js
22 строки
496 B
boolyshareyo
Initial commit
08 июн 2026, 16:00
08 июн 2026, 16:00
6216a29
Код
Авторство
О чём код?
function safeRequestAnimationFrame(callback) { if (typeof requestAnimationFrame !== 'undefined') requestAnimationFrame(callback); } export default function setRafTimeout(callback, timeout = 0) { let currTime = -1; const shouldUpdate = now => { if (currTime < 0) { currTime = now; } if (now - currTime > timeout) { callback(now); currTime = -1; } else { safeRequestAnimationFrame(shouldUpdate); } }; requestAnimationFrame(shouldUpdate); }