@lagrange/animator
Version:
This library helps making parallax animations on scroll. It is built with performance in mind, as it doesn't need to relayout or paint to operate.
35 lines (31 loc) • 720 B
JavaScript
import constrainValues from './constrainValues';
import precision from './precision';
/**
* @param {AnimatorElement} el
* @param {number} st
*/
export default function transformValues(el, st) {
return el.keys.map((propKey) => {
return {
st,
ease: el.ease,
key: propKey,
...el.keyframes[propKey]
.reduce((propCarry, propVal, i) => {
const [offset, value] = propVal;
switch (i) {
case 0:
propCarry.startOffset = offset;
propCarry.startValue = value;
break;
case 1:
default:
propCarry.endOffset = offset;
propCarry.endValue = value;
break;
}
return propCarry;
}, {}),
};
}).reduce(constrainValues, {});
}