🎥 Make videos programmatically with React
rename to durationInFrames
Jonny Burger3e0b1037bd38
diff --git a/packages/core/src/spring/index.ts b/packages/core/src/spring/index.tsindex 83b5b3a638..4fffcc364b 100644--- a/packages/core/src/spring/index.ts+++ b/packages/core/src/spring/index.ts@@ -15,7 +15,7 @@ import {springCalculation} from './spring-utils';* @param {boolean} [config.overshootClamping=false] Whether to prevent the animation going beyond the target value.* @param {?number} [config.from] The initial value of the animation. Default `0`* @param {?number} [config.to] The end value of the animation. Default `1`- * @param {?number} [config.duration] Stretch the duration of an animation to a set value.. Default `undefined`+ * @param {?number} [config.durationInFrames] Stretch the duration of an animation to a set value.. Default `undefined`* @param {?number} [config.durationThreshold] How close to the end the animation is considered to be done. Default `0.005`*/export function spring({@@ -24,7 +24,7 @@ export function spring({config = {},from = 0,to = 1,- duration,+ durationInFrames,durationThreshold,}: {frame: number;@@ -32,12 +32,12 @@ export function spring({config?: Partial<SpringConfig>;from?: number;to?: number;- duration?: number;+ durationInFrames?: number;durationThreshold?: number;}): number {- validateSpringDuration(duration);- const durationRatio = duration- ? duration /+ validateSpringDuration(durationInFrames);+ const durationRatio = durationInFrames+ ? durationInFrames /measureSpring({fps, config, from, to, threshold: durationThreshold}): 1;diff --git a/packages/core/src/test/spring.test.ts b/packages/core/src/test/spring.test.tsindex 0727d82a9f..4447300da8 100644--- a/packages/core/src/test/spring.test.ts+++ b/packages/core/src/test/spring.test.ts@@ -50,7 +50,7 @@ describe('Should be able to set duration for spring', () => {spring({fps: 30,frame: 5,- duration: 5,+ durationInFrames: 5,})).toBe(1);});diff --git a/packages/docs/docs/spring.md b/packages/docs/docs/spring.mdindex bfec02e76d..3f7d20df53 100644--- a/packages/docs/docs/spring.md+++ b/packages/docs/docs/spring.md@@ -3,7 +3,7 @@ id: springtitle: spring()----Delightful and smooth animation primitive. Calculates a position based on physical parameters, start and end value, and time.+A physics-based animation primitive.Example:@@ -11,13 +11,11 @@ Example:import { spring, useCurrentFrame, useVideoConfig } from "remotion";// ---cut---const frame = useCurrentFrame();-const videoConfig = useVideoConfig();+const { fps } = useVideoConfig();const value = spring({frame,- from: 0,- to: 1,- fps: videoConfig.fps,+ fps,config: {stiffness: 100,},@@ -74,6 +72,28 @@ _Default_: `false`Determines whether the animation can shoot over the `to` value. If set to true, if the animation goes over `to`, it will just return the value of `to`.+### durationInFrames++_Available from v3.0.26_++Stretches the animation curve so it is exactly as long as you specify.++```tsx twoslash+import { spring, useCurrentFrame, useVideoConfig } from "remotion";+// ---cut---+const frame = useCurrentFrame();+const { fps } = useVideoConfig();++const value = spring({+ frame,+ fps,+ config: {+ stiffness: 100,+ },+ durationInFrames: 40,+});+```+## YouTube videoWant to understand the different properties like `mass`, `stiffness`, `damping` etc.? We made a video trying to make sense of all the parameters!diff --git a/packages/example/src/Spring/base-spring.tsx b/packages/example/src/Spring/base-spring.tsxindex 452b947290..1d53c35bef 100644--- a/packages/example/src/Spring/base-spring.tsx+++ b/packages/example/src/Spring/base-spring.tsx@@ -21,7 +21,7 @@ export const BaseSpring: React.FC = () => {frame,fps,config: {},- duration: 90,+ durationInFrames: 90,})})`,}}/>