color-js / elements

WIP
13 stars 1 forks source link

[color-gamut] Changing `Chroma increments` parameter in the Demo hangs the page #15

Closed DmitrySharabin closed 5 months ago

DmitrySharabin commented 6 months ago

In all browsers.

The Demo

DmitrySharabin commented 5 months ago

This happens because of an infinite loop we might get when Chroma increments becomes equal to 0. This means that step (L58) becomes equal to 0. And the following loop (L66-68) becomes infinite:

for (let c = c_range.min; c<= c_range.max; c+=step) {
    colors.push(`oklch(${l.value}% ${c.toLocaleString("en")}% ${h.value})`);
}

The fix is rather simple (L52):

- <input type=number id=c_step value="0.2" min="0">
+ <input type=number id=c_step value="0.2" min="0.1" step="0.1">

We might want to adjust step, but min should never be equal to 0.