Skip to content

🎥 Make videos programmatically with React

Update timing.md

Jonny Burger071437cb952b
diff --git a/packages/skills/skills/remotion/rules/timing.md b/packages/skills/skills/remotion/rules/timing.md
index 9681efd87e..464d4e29cd 100644
--- a/packages/skills/skills/remotion/rules/timing.md
+++ b/packages/skills/skills/remotion/rules/timing.md
@@ -1,6 +1,6 @@
---
name: timing
-description: Interpolation curves in Remotion - linear, easing, spring animations
+description: Interpolation curves in Remotion - linear, easing, spring animations
metadata:
tags: spring, bounce, easing, interpolation
---
@@ -8,7 +8,7 @@ metadata:
A simple linear interpolation is done using the `interpolate` function.
```ts title="Going from 0 to 1 over 100 frames"
-import { interpolate } from 'remotion';
+import {interpolate} from 'remotion';
const opacity = interpolate(frame, [0, 100], [0, 1]);
```
@@ -19,7 +19,7 @@ Here is how they can be clamped:
```ts title="Going from 0 to 1 over 100 frames with extrapolation"
const opacity = interpolate(frame, [0, 100], [0, 1], {
extrapolateRight: 'clamp',
- extrapolateLeft: 'clamp'
+ extrapolateLeft: 'clamp',
});
```
@@ -29,10 +29,10 @@ Spring animations have a more natural motion.
They go from 0 to 1 over time.
```ts title="Spring animation from 0 to 1 over 100 frames"
-import { spring, useCurrentFrame, useVideoConfig } from 'remotion';
+import {spring, useCurrentFrame, useVideoConfig} from 'remotion';
const frame = useCurrentFrame();
-const { fps } = useVideoConfig();
+const {fps} = useVideoConfig();
const scale = spring({
frame,
@@ -75,7 +75,7 @@ Use the `delay` parameter to delay the animation by a number of frames.
const entrance = spring({
frame: frame - ENTRANCE_DELAY,
fps,
- delay: 20
+ delay: 20,
});
```
@@ -88,7 +88,7 @@ To stretch the animation to a specific duration, use the `durationInFrames` para
const spring = spring({
frame,
fps,
- durationInFrames: 40
+ durationInFrames: 40,
});
```
@@ -105,7 +105,7 @@ const springProgress = spring({
// Map to rotation
const rotation = interpolate(springProgress, [0, 1], [0, 360]);
-<div style={{ rotation: rotation + 'deg }} />
+<div style={{rotate: rotation + 'deg'}} />;
```
### Adding springs
@@ -118,13 +118,13 @@ const {fps, durationInFrames} = useVideoConfig();
const inAnimation = spring({
frame,
- fps
+ fps,
});
const outAnimation = spring({
frame,
fps,
- durationInFrames: 30,
- delay: durationInFrames - 30
+ durationInFrames: 1 * fps,
+ delay: durationInFrames - 1 * fps,
});
const scale = inAnimation - outAnimation;
@@ -137,16 +137,11 @@ Easing can be added to the `interpolate` function:
```ts
import {interpolate, Easing} from 'remotion';
-const value1 = interpolate(
- frame,
- [0, 100],
- [0, 1],
- {
- easing: Easing.inOut(Easing.quad),
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- }
-);
+const value1 = interpolate(frame, [0, 100], [0, 1], {
+ easing: Easing.inOut(Easing.quad),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+});
```
The default easing is `Easing.linear`.
@@ -166,29 +161,19 @@ and curves (sorted from most linear to most curved):
Convexities and curves need be combined for an easing function:
```ts
-const value1 = interpolate(
- frame,
- [0, 100],
- [0, 1],
- {
- easing: Easing.inOut(Easing.quad),
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- }
-);
+const value1 = interpolate(frame, [0, 100], [0, 1], {
+ easing: Easing.inOut(Easing.quad),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+});
```
Cubic bezier curves are also supported:
```ts
-const value1 = interpolate(
- frame,
- [0, 100],
- [0, 1],
- {
- easing: Easing.bezier(0.8, 0.22, 0.96, 0.65),
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- }
-);
-```
\ No newline at end of file
+const value1 = interpolate(frame, [0, 100], [0, 1], {
+ easing: Easing.bezier(0.8, 0.22, 0.96, 0.65),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+});
+```