🎥 Make videos programmatically with React
explain durationRestThreshold
Jonny Burger9bc5850d6f06
diff --git a/packages/core/src/spring/index.ts b/packages/core/src/spring/index.tsindex e580a904fb..ff891bffa3 100644--- a/packages/core/src/spring/index.ts+++ b/packages/core/src/spring/index.ts@@ -25,7 +25,7 @@ export function spring({from = 0,to = 1,durationInFrames,- durationThreshold,+ durationRestThreshold,}: {frame: number;fps: number;@@ -33,14 +33,22 @@ export function spring({from?: number;to?: number;durationInFrames?: number;- durationThreshold?: number;+ durationRestThreshold?: number;}): number {validateSpringDuration(durationInFrames);+const durationRatio =durationInFrames === undefined? 1: durationInFrames /- measureSpring({fps, config, from, to, threshold: durationThreshold});+ measureSpring({+ fps,+ config,+ from,+ to,+ threshold: durationRestThreshold,+ });+const spr = springCalculation({fps,frame: frame / durationRatio,diff --git a/packages/docs/docs/spring.md b/packages/docs/docs/spring.mdindex 2ec7c93538..c1a3005bde 100644--- a/packages/docs/docs/spring.md+++ b/packages/docs/docs/spring.md@@ -74,7 +74,7 @@ Determines whether the animation can shoot over the `to` value. If set to true,### durationInFrames-_Available from v3.0.27_+_Available from v3.0.27 - optional_Stretches the animation curve so it is exactly as long as you specify.@@ -94,6 +94,14 @@ const value = spring({});```+## `durationRestThreshold`++_Available from v3.0.27 - optional_++How close the animation can be to the end in order to be considered finished for the calculation of the duration. Only has an effect if `durationInFrames` is also specified.++For example, if a `durationRestThreshold` of `0.001` is given, and the durationOfFrames is `30`, it means that after 30 frames, the spring has reached 99.9% (`1 - 0.001 = 0.999`) of it's distance to the end value.+## YouTube videoWant to understand the different properties like `mass`, `stiffness`, `damping` etc.? We made a video trying to make sense of all the parameters!