Skip to content

Commit

Permalink
Add support for negative CSS values (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
egirard authored Sep 27, 2023
1 parent 456e9cd commit a4b62f3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/scroll-timeline-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export function calculateMaxScrollOffset(source, axis) {

function resolvePx(cssValue, resolvedLength) {
if (cssValue instanceof CSSUnitValue) {
// TODO: Add support for em, vh
if (cssValue.unit == "percent")
return cssValue.value * resolvedLength / 100;
else if (cssValue.unit == "px")
Expand All @@ -115,7 +116,9 @@ function resolvePx(cssValue, resolvedLength) {
total += resolvePx(value, resolvedLength);
}
return total;
}
} else if (cssValue instanceof CSSMathNegate) {
return -resolvePx(cssValue.value, resolvedLength);
}
throw TypeError("Unsupported value type: " + typeof(cssValue));
}

Expand Down

0 comments on commit a4b62f3

Please sign in to comment.