mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-17 02:34:38 -05:00
use 30fps (should help #65)
This commit is contained in:
parent
09aab0784a
commit
866e0b853d
1 changed files with 12 additions and 3 deletions
|
@ -1890,10 +1890,19 @@ if (/[?&]autoplay=/.test(location.search)) {
|
|||
|
||||
<script>
|
||||
let requestId;
|
||||
let lastDrawTime = 0; // Timestamp of the last draw request
|
||||
|
||||
const loopStart = () => {
|
||||
requestId = window.requestAnimationFrame(loopStart)
|
||||
}
|
||||
const now = performance.now();
|
||||
const elapsed = now - lastDrawTime;
|
||||
if (elapsed >= (1000 / 30)) { // Adjusted for milliseconds
|
||||
lastDrawTime = now;
|
||||
draw();
|
||||
}
|
||||
|
||||
// Continue loop using requestAnimationFrame
|
||||
requestId = window.requestAnimationFrame(loopStart);
|
||||
};
|
||||
|
||||
const loopCancel = () => {
|
||||
window.cancelAnimationFrame(requestId)
|
||||
|
|
Loading…
Reference in a new issue