mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 08:47:53 +01: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,11 +1890,20 @@ 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)
|
||||
requestId = undefined
|
||||
|
|
Loading…
Reference in a new issue