From a4b62f3b5fd9b936e139fd65c95fb5c513046d0d Mon Sep 17 00:00:00 2001 From: egirard Date: Wed, 27 Sep 2023 09:01:22 -0400 Subject: [PATCH] Add support for negative CSS values (#161) --- src/scroll-timeline-base.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/scroll-timeline-base.js b/src/scroll-timeline-base.js index f85c81d3..dae674bb 100644 --- a/src/scroll-timeline-base.js +++ b/src/scroll-timeline-base.js @@ -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") @@ -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)); }