Trig-JS icon indicating copy to clipboard operation
Trig-JS copied to clipboard

[FEATURE] Css Variable without unit

Open glucka opened this issue 6 months ago • 2 comments

I think it could be great if a can use --trig vlaues without % or px unit. For example for scroll dynamic opacity or scale.

The question is we need units at all? Because i can solve that with css too.

calc(var(--trig)*1px) or calc(var(--trig)*1%)

glucka avatar Jun 05 '25 12:06 glucka

"reverse" can solve with css calc too calc(var(--trig)*-1px)

glucka avatar Jun 05 '25 12:06 glucka

Sorry for the late reply. If the px or % is taken away then you can't directly use the trig var without calc.

so

transform:translateY(var(--trig));

would no longer work.

I'm doing opacity in the docs like this:

opacity: calc(var(--trig));
transition: opacity ease-out 0.3s;

I've not tried multiplication by percent or pixels but the other way around works:

transform:translateY(calc(var(--trig) * 2));

or

transform:translateY(calc(var(--trig-px) * 2));

iDev-Games avatar Jun 16 '25 11:06 iDev-Games