Skip to content

Commit e856c22

Browse files
committed
better verbose variables
1 parent 1d94637 commit e856c22

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

CSSVarTransition.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

22
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
33

4-
async function transitionRGB(variable, target, seconds = 1000, steps = 10) {
4+
async function transitionRGB(variable, target, duration = 1000, steps = 10) {
5+
56
const rgb = getComputedStyle(document.documentElement)
67
.getPropertyValue(variable)
78
.split(",")
@@ -20,14 +21,14 @@ async function transitionRGB(variable, target, seconds = 1000, steps = 10) {
2021
const redTarg = target[0];
2122
const greenTarg = target[1];
2223
const blueTarg = target[2];
23-
const stepTime = seconds / steps;
24-
console.log(stepTime)
24+
const stepDuration = duration / steps;
25+
2526
let loops = 0;
27+
2628
const redStep = Math.floor((redTarg - red) / steps)
2729
const greenStep = Math.floor((greenTarg - green) / steps)
2830
const blueStep = Math.floor((blueTarg - blue) / steps)
2931

30-
console.log(redStep)
3132

3233
while (loops < steps) {
3334
loops += 1
@@ -37,7 +38,7 @@ async function transitionRGB(variable, target, seconds = 1000, steps = 10) {
3738
document.body.style.setProperty(
3839
variable, `${red}, ${green}, ${blue}`
3940
);
40-
await delay(stepTime);
41+
await delay(stepDuration);
4142
}
4243

4344
document.body.style.setProperty(

0 commit comments

Comments
 (0)