I'm storing a value in the DOM right now using javascript:
document.documentElement.style.setProperty('--offset', offset+'px')
later on, I use it as a part of a calculation in an animaiton:
@keyframes upanim {
from {transform: translate3d(0,calc(var(--offset) - 100vh ),0);}
to {transform: translate3d(0,0,0);}
}
I now want to use that same value to calculate the speed of that animation, so that the speed is always the same number of pixels/second:
animation: upanim calc(var(--offset) * 0.002)s cubic-bezier(0, 0, 0.25, 1);
The problem is the 'px' and 's', I would like to add the unit inside the calculation instead and just store the value in the DOM. Is this possible?