function animate({
  fromValue,
  toValue,
  onUpdate,
  onComplete,
  duration = 600,
}) {
  const startTime = performance.now();

  const tick = () => {
    const elapsed = performance.now() - startTime;

    window.requestAnimationFrame(() => onUpdate(
      getValue(fromValue, toValue, elapsed, duration),
      // Callback
      elapsed <= duration
        ? tick
        : onComplete
    ));
  };

  tick();
}
Smoothly animate between two values
@param {Number} fromValue - the initial value
@param {Function} onUpdate - A function that is called on each tick
@param {Function} onComplete - A callback that is fired once the scroll animation ends
@param {Number} duration - the desired duration of the scroll animation