flackr / scroll-timeline

A polyfill of ScrollTimeline.
Apache License 2.0
887 stars 82 forks source link

Use simplicyCalculation to resolve px #228

Closed johannesodland closed 5 months ago

johannesodland commented 5 months ago

Using simplifyCalculation() in resolvePx() to resolve CSSMathValues and CSSUnitValues according to spec. Swithcing to using resolvePx() elsewhere, in stead of calling simplicyCalculation() directly.

This gives us one unified code path to resolving px values from CSSNumericValues.

resolvePx() now takes an info/context object that simplifyCalculation() can use to resolve relative units. Ritght now it supports percentageReference and fontSize, but can be extended with values so that we can resolve all relative units, such as viewport units.

The context object is now called info but could benefit from a more descriptive name. Suggestions are welcome :)

flackr commented 5 months ago

Note that for each bit of information we pass in to info we technically should invalidate when that info changes.