🎥 Make videos programmatically with React
assign proper start index for 'input range' arg of interpolate styles function, fixes #3922
Abhishek Kumar Gupta4737e73b65d9
diff --git a/packages/animation-utils/src/test/interpolate-styles.test.ts b/packages/animation-utils/src/test/interpolate-styles.test.tsindex 39e550cd55..302d827418 100644--- a/packages/animation-utils/src/test/interpolate-styles.test.ts+++ b/packages/animation-utils/src/test/interpolate-styles.test.ts@@ -325,3 +325,21 @@ test('Should handle negative values in transforms well', () => {transform: 'translate(100px, 0px)',});});++// Refer https://github.com/remotion-dev/remotion/issues/3922+test('Should assign proper start value from interpolate\'s inputRange array if first element is greater than input value', () => {+ expect(+ interpolateStyles(+ 1.5,+ [2, 3],+ [+ {+ opacity: 0,+ },+ {+ opacity: 1,+ },+ ],+ ),+ ).toEqual({opacity: -0.5});+});diff --git a/packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsx b/packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsxindex e47d8195ca..8273a1222f 100644--- a/packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsx+++ b/packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsx@@ -291,6 +291,10 @@ export const interpolateStyles = (checkStylesRange(outputStylesRange);let startIndex = inputRange.findIndex((step) => input < step) - 1;+ if (startIndex === -1) {+ startIndex = 0;+ }+if (startIndex === -2) {startIndex = inputRange.length - 2;}