Skip to content

🎥 Make videos programmatically with React

some polish

Jonny Burgera475790e55c3
diff --git a/packages/docs/docs/spring.md b/packages/docs/docs/spring.md
index c1a3005bde..d5fc107946 100644
--- a/packages/docs/docs/spring.md
+++ b/packages/docs/docs/spring.md
@@ -98,7 +98,7 @@ const value = spring({
_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.
+How close the animation should 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.
diff --git a/packages/example/src/Spring/base-spring.tsx b/packages/example/src/Spring/base-spring.tsx
index 1d53c35bef..6bf2bcbf13 100644
--- a/packages/example/src/Spring/base-spring.tsx
+++ b/packages/example/src/Spring/base-spring.tsx
@@ -2,6 +2,33 @@ import React from 'react';
import {AbsoluteFill, spring, useCurrentFrame, useVideoConfig} from 'remotion';
export const BaseSpring: React.FC = () => {
+ const frame = useCurrentFrame();
+ const {fps} = useVideoConfig();
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}
+ >
+ <div
+ style={{
+ height: 200,
+ width: 200,
+ backgroundColor: 'red',
+ borderRadius: 100,
+ transform: `scale(${spring({
+ frame,
+ fps,
+ config: {},
+ })})`,
+ }}
+ />
+ </AbsoluteFill>
+ );
+};
+
+export const SpringWithDuration: React.FC = () => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
return (
diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsx
index 8c71de5dca..3120d261a1 100644
--- a/packages/example/src/Video.tsx
+++ b/packages/example/src/Video.tsx
@@ -18,7 +18,7 @@ import InfinityVideo from './ReallyLongVideo';
import RemoteVideo from './RemoteVideo';
import {Scripts} from './Scripts';
import {SkipZeroFrame} from './SkipZeroFrame';
-import {BaseSpring} from './Spring/base-spring';
+import {BaseSpring, SpringWithDuration} from './Spring/base-spring';
import {SeriesTesting} from './StaggerTesting';
import {StaticDemo} from './StaticServer';
import {TenFrameTester} from './TenFrameTester';
@@ -90,6 +90,14 @@ export const Index: React.FC = () => {
fps={30}
durationInFrames={100}
/>
+ <Composition
+ id="spring-with-duration"
+ component={SpringWithDuration}
+ width={1080}
+ height={1080}
+ fps={30}
+ durationInFrames={100}
+ />
</Folder>
<Folder name="regression-testing">
<Composition