mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 16:17:52 +01:00
gush
This commit is contained in:
parent
2ab6bb1c89
commit
02a13a9325
1 changed files with 15 additions and 4 deletions
|
@ -1797,6 +1797,20 @@ const draw = () => {
|
|||
}
|
||||
|
||||
|
||||
// Adjust the frame rate by changing the interval
|
||||
const frameRate = 4; // Set the desired frame rate in milliseconds
|
||||
|
||||
const drawLoopWithInterval = () => {
|
||||
const now = performance.now();
|
||||
|
||||
if (!lastDraw || now - lastDraw >= frameRate) {
|
||||
draw();
|
||||
lastDraw = now;
|
||||
}
|
||||
|
||||
step = window.requestAnimationFrame(drawLoopWithInterval);
|
||||
};
|
||||
|
||||
const drawLoop = () => {
|
||||
draw()
|
||||
|
||||
|
@ -1813,10 +1827,7 @@ const drawPause = () => {
|
|||
const init = () => {
|
||||
AMvideo.addEventListener("loadeddata", drawLoop, false)
|
||||
AMvideo.addEventListener("seeked", draw, false)
|
||||
AMvideo.addEventListener("play", () => {
|
||||
// Start the draw loop with a target frame rate of 250 frames per second (1 / 0.004)
|
||||
step = window.requestAnimationFrame(drawLoop);
|
||||
}, false);
|
||||
AMvideo.addEventListener("play", drawLoopWithInterval, false);
|
||||
AMvideo.addEventListener("pause", drawPause, false)
|
||||
AMvideo.addEventListener("ended", drawPause, false)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue