motion-dom 14.1.0 → 14.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -805,7 +805,20 @@ function calcGeneratorDuration(generator, timeStep = 50, maxDuration = maxGenera
805
805
  * Create a progress => progress easing function from a generator.
806
806
  */
807
807
  function createGeneratorEasing(options, scale = 100, createGenerator) {
808
- const generator = createGenerator({ ...options, keyframes: [0, scale] });
808
+ /**
809
+ * The easing is generated over 0 - scale, but velocity is in the
810
+ * value's own units, so scale it to match. Otherwise an interrupted
811
+ * spring hands off the wrong speed, or direction. Keyframes with
812
+ * units (colours, filters, mixed units) give NaN, which is falsy,
813
+ * so their velocity passes through unscaled.
814
+ */
815
+ const { keyframes: k, velocity: v } = options;
816
+ const delta = k && k[k.length - 1] - k[0];
817
+ const generator = createGenerator({
818
+ ...options,
819
+ velocity: v && delta ? (v * scale) / delta : v,
820
+ keyframes: [0, scale],
821
+ });
809
822
  const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
810
823
  return {
811
824
  type: "keyframes",