From 1be3525ee50a222103f96166766f67536016f54d Mon Sep 17 00:00:00 2001 From: josephsmendoza Date: Thu, 1 Dec 2022 05:57:16 +0000 Subject: [PATCH] add --random-timeout --- CSSRandom.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CSSRandom.js b/CSSRandom.js index 844514b..5ad1afb 100644 --- a/CSSRandom.js +++ b/CSSRandom.js @@ -1,4 +1,10 @@ -(function CSSRandom(){ - document.body.style.setProperty('--random',Math.random()) - requestAnimationFrame(CSSRandom) -})() \ No newline at end of file +const style=document.body.style +function CSSRandom(){ + style.setProperty('--random',Math.random()) + const timeout=style.getPropertyValue('--random-timeout') + if(timeout){ + setTimeout(CSSRandom,parseInt(timeout)) + }else{ + requestAnimationFrame(CSSRandom) + } +} \ No newline at end of file