Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: page turn
kapishdimade1ef665679d
diff --git a/components/docs/examples/page-turn-example.tsx b/components/docs/examples/page-turn-example.tsxnew file mode 100644index 00000000..a6472ee4--- /dev/null+++ b/components/docs/examples/page-turn-example.tsx@@ -0,0 +1,85 @@+"use client";++import { linearTiming, TransitionSeries } from "@remotion/transitions";+import { AbsoluteFill } from "remotion";+import { pageTurn } from "@/registry/remocn/page-turn";++const FONT_FAMILY =+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif";++function Page({+ label,+ background,+ color,+}: {+ label: string;+ background: string;+ color: string;+}) {+ return (+ <AbsoluteFill+ style={{+ background,+ alignItems: "center",+ justifyContent: "center",+ }}+ >+ <span+ style={{+ fontFamily: FONT_FAMILY,+ fontSize: 96,+ fontWeight: 600,+ color,+ }}+ >+ {label}+ </span>+ </AbsoluteFill>+ );+}++interface PageTurnExampleProps {+ angle?: number;+ poses?: number;+}++export function PageTurnExampleScene({ angle, poses }: PageTurnExampleProps) {+ return (+ <TransitionSeries>+ <TransitionSeries.Sequence durationInFrames={76}>+ <Page label="Page one" background="#f1eee7" color="#26242c" />+ </TransitionSeries.Sequence>+ <TransitionSeries.Transition+ timing={linearTiming({ durationInFrames: 24 })}+ presentation={pageTurn({ angle, poses })}+ />+ <TransitionSeries.Sequence durationInFrames={76}>+ <Page label="Page two" background="#e6e1d5" color="#6f7f35" />+ </TransitionSeries.Sequence>+ </TransitionSeries>+ );+}++export const pageTurnExampleCode = (+ values: Record<string, unknown>,+): string => {+ const angle = (values.angle as number) ?? -7;+ const poses = (values.poses as number) ?? 8;+ return `import { TransitionSeries, linearTiming } from "@remotion/transitions";+import { pageTurn } from "@/components/remocn/page-turn";++export const MyVideo = () => (+ <TransitionSeries>+ <TransitionSeries.Sequence durationInFrames={76}>+ <PageOne />+ </TransitionSeries.Sequence>+ <TransitionSeries.Transition+ timing={linearTiming({ durationInFrames: 24 })}+ presentation={pageTurn({ angle: ${angle}, poses: ${poses} })}+ />+ <TransitionSeries.Sequence durationInFrames={76}>+ <PageTwo />+ </TransitionSeries.Sequence>+ </TransitionSeries>+);`;+};diff --git a/content/docs/components.mdx b/content/docs/components.mdxindex dadfc655..58105be3 100644--- a/content/docs/components.mdx+++ b/content/docs/components.mdx@@ -395,6 +395,12 @@ Scene transitions, camera moves, and stylized wipes.status: "stable",href: "/docs/transitions/zoom-blur",},+ {+ name: "PageTurn",+ description: "The exiting scene swings up and away like a notebook page in stop-motion poses",+ status: "stable",+ href: "/docs/transitions/page-turn",+ },]}/>diff --git a/content/docs/transitions/meta.json b/content/docs/transitions/meta.jsonindex 061f16c9..9ecd8b9e 100644--- a/content/docs/transitions/meta.json+++ b/content/docs/transitions/meta.json@@ -14,6 +14,7 @@"whip-pan","push-through","focus-pull",- "zoom-blur"+ "zoom-blur",+ "page-turn"]}diff --git a/content/docs/transitions/page-turn.mdx b/content/docs/transitions/page-turn.mdxnew file mode 100644index 00000000..0fe94c8d--- /dev/null+++ b/content/docs/transitions/page-turn.mdx@@ -0,0 +1,84 @@+---+title: Page Turn+description: The exiting scene swings up and away like a notebook page in stop-motion poses+---++<ComponentPreview name="page-turn" />++## Installation++<InstallBlock name="page-turn" />++## Usage++`pageTurn` is a `TransitionPresentation` for `@remotion/transitions`. The+outgoing scene lifts and rotates away like a page being turned; the incoming+scene is simply already there, underneath.++```tsx+// src/Root.tsx+import { linearTiming, TransitionSeries } from "@remotion/transitions";+import { pageTurn } from "@/components/remocn/page-turn";++export const MyVideo = () => (+ <TransitionSeries>+ <TransitionSeries.Sequence durationInFrames={76}>+ <PageOne />+ </TransitionSeries.Sequence>+ <TransitionSeries.Transition+ timing={linearTiming({ durationInFrames: 24 })}+ presentation={pageTurn()}+ />+ <TransitionSeries.Sequence durationInFrames={76}>+ <PageTwo />+ </TransitionSeries.Sequence>+ </TransitionSeries>+);+```++24 frames is the pairing this transition was built around — eight poses at the+kit's default tempo of three frames each.++### The exiting scene stays on top++This is the one transition in the catalog that inverts the usual stacking. In a+`TransitionSeries` the entering scene normally paints over the outgoing one;+here the outgoing wrapper takes `zIndex: 2`, because a page you are turning has+to pass in front of whatever it uncovers. The entering scene is rendered+completely untouched — no fade, no transform. The reveal *is* the entering+animation.++### Poses, not a sweep++Progress is eased, then snapped to `poses` discrete values, so the page moves in+hand-shot jumps rather than gliding. That happens inside the presentation, so it+survives whichever timing function you pass — `springTiming` will change how+long each pose is held, but it cannot smooth the motion back out.++Lower `poses` for a rougher, more obviously hand-made turn; raise it toward 16+and the page starts to look mechanical.++## Props++<PropsTable+ rows={[+ {+ name: "angle",+ type: "number",+ default: "-7",+ description: "Rotation in degrees at full lift; negative swings the page left",+ },+ {+ name: "origin",+ type: "string",+ default: "\"18% 100%\"",+ description: "CSS transform-origin the page pivots around",+ },+ {+ name: "poses",+ type: "number",+ default: "8",+ description: "How many discrete stop-motion poses the turn is snapped to",+ },+ ]}+/>diff --git a/registry-artifacts/page-turn.json b/registry-artifacts/page-turn.jsonnew file mode 100644index 00000000..174ba8f0--- /dev/null+++ b/registry-artifacts/page-turn.json@@ -0,0 +1,16 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "page-turn",+ "title": "Page Turn",+ "description": "The exiting scene swings up and away like a notebook page in stop-motion poses, staying above the scene it reveals.",+ "dependencies": ["remotion", "@remotion/transitions"],+ "files": [+ {+ "path": "registry/remocn/page-turn/index.tsx",+ "content": "\"use client\";\n\nimport type {\n TransitionPresentation,\n TransitionPresentationComponentProps,\n} from \"@remotion/transitions\";\nimport type React from \"react\";\nimport { AbsoluteFill, useVideoConfig } from \"remotion\";\n\nconst LIFT_RATIO = 1.28;\n\nexport function pageTurnPose(progress: number, poses: number): number {\n const clamped = Math.min(1, Math.max(0, progress));\n const eased = clamped ** 3;\n if (poses <= 1) return eased >= 1 ? 1 : 0;\n const bucket = Math.min(poses - 1, Math.floor(eased * poses));\n return bucket / (poses - 1);\n}\n\nexport type PageTurnProps = {\n angle?: number;\n origin?: string;\n poses?: number;\n};\n\nconst PageTurnPresentation: React.FC<\n TransitionPresentationComponentProps<PageTurnProps>\n> = ({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n}) => {\n const { height } = useVideoConfig();\n const { angle = -7, origin = \"18% 100%\", poses = 8 } = passedProps;\n\n if (presentationDirection === \"entering\") {\n return <AbsoluteFill>{children}</AbsoluteFill>;\n }\n\n const pose = pageTurnPose(presentationProgress, poses);\n\n return (\n <AbsoluteFill\n style={{\n zIndex: 2,\n transformOrigin: origin,\n transform: `translateY(${-pose * height * LIFT_RATIO}px) rotate(${angle * pose}deg)`,\n }}\n >\n {children}\n </AbsoluteFill>\n );\n};\n\nexport function pageTurn(\n props: PageTurnProps = {},\n): TransitionPresentation<PageTurnProps> {\n return {\n component: PageTurnPresentation,\n props,\n };\n}\n",+ "type": "registry:component",+ "target": "components/remocn/page-turn.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.jsonindex a1f6582a..c27c032b 100644--- a/registry-artifacts/registry.json+++ b/registry-artifacts/registry.json@@ -1373,6 +1373,20 @@],"type": "registry:component"},+ {+ "name": "page-turn",+ "title": "Page Turn",+ "description": "The exiting scene swings up and away like a notebook page in stop-motion poses, staying above the scene it reveals.",+ "dependencies": ["remotion", "@remotion/transitions"],+ "files": [+ {+ "path": "registry/remocn/page-turn/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/page-turn.tsx"+ }+ ],+ "type": "registry:component"+ },{"name": "stop-motion","title": "Stop Motion Clock",diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex f9e96e27..f0134f59 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -39,6 +39,7 @@ import { matrixDecodeConfig } from "@/registry/remocn/matrix-decode/config";import { microScaleFadeConfig } from "@/registry/remocn/micro-scale-fade/config";import { numberWheelConfig } from "@/registry/remocn/number-wheel/config";import { opencodeConfig } from "@/registry/remocn/opencode/config";+import { pageTurnConfig } from "@/registry/remocn/page-turn/config";import { paperStickerConfig } from "@/registry/remocn/paper-sticker/config";import { paperWobbleConfig } from "@/registry/remocn/paper-wobble/config";import { perCharacterRiseConfig } from "@/registry/remocn/per-character-rise/config";@@ -1556,6 +1557,13 @@ const registry: Record<string, RegistryEntry> = {})),config: polaroidConfig,},+ "page-turn": {+ load: () =>+ import("@/components/docs/examples/page-turn-example").then((m) => ({+ default: m.PageTurnExampleScene,+ })),+ config: pageTurnConfig,+ },"ink-arrow": {load: () =>import("@/components/docs/examples/ink-arrow-example").then((m) => ({diff --git a/registry/remocn/page-turn/__tests__/page-turn.test.ts b/registry/remocn/page-turn/__tests__/page-turn.test.tsnew file mode 100644index 00000000..35425453--- /dev/null+++ b/registry/remocn/page-turn/__tests__/page-turn.test.ts@@ -0,0 +1,61 @@+import { describe, expect, it } from "bun:test";++import { pageTurnPose } from "../index";++const sample = (poses: number, steps = 400) =>+ Array.from({ length: steps + 1 }, (_, i) => pageTurnPose(i / steps, poses));++describe("pageTurnPose", () => {+ it("hits the ends exactly", () => {+ for (const poses of [2, 4, 8, 16]) {+ expect(pageTurnPose(0, poses)).toBe(0);+ expect(pageTurnPose(1, poses)).toBe(1);+ }+ });++ it("never decreases", () => {+ for (const poses of [2, 8, 16]) {+ const values = sample(poses);+ for (let i = 1; i < values.length; i++) {+ expect(values[i]).toBeGreaterThanOrEqual(values[i - 1]);+ }+ }+ });++ it("produces exactly `poses` distinct values", () => {+ for (const poses of [2, 4, 8, 16]) {+ expect(new Set(sample(poses)).size).toBe(poses);+ }+ });++ it("stays inside [0, 1]", () => {+ for (const value of sample(8)) {+ expect(value).toBeGreaterThanOrEqual(0);+ expect(value).toBeLessThanOrEqual(1);+ }+ });++ it("holds a plateau then jumps", () => {+ const values = sample(8, 800);+ const jumps = values.filter((v, i) => i > 0 && v !== values[i - 1]).length;+ expect(jumps).toBe(7);+ });++ it("eases in — the first pose lasts longer than the last", () => {+ const values = sample(8, 800);+ const first = values.filter((v) => v === values[0]).length;+ const last = values.filter((v) => v === 1).length;+ expect(first).toBeGreaterThan(last);+ });++ it("clamps progress outside [0, 1]", () => {+ expect(pageTurnPose(-0.5, 8)).toBe(0);+ expect(pageTurnPose(1.5, 8)).toBe(1);+ });++ it("degrades safely for poses <= 1", () => {+ expect(pageTurnPose(0.5, 1)).toBe(0);+ expect(pageTurnPose(1, 1)).toBe(1);+ expect(Number.isNaN(pageTurnPose(0.5, 0))).toBe(false);+ });+});diff --git a/registry/remocn/page-turn/config.ts b/registry/remocn/page-turn/config.tsnew file mode 100644index 00000000..7669c54e--- /dev/null+++ b/registry/remocn/page-turn/config.ts@@ -0,0 +1,31 @@+import { pageTurnExampleCode } from "@/components/docs/examples/page-turn-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const pageTurnConfig: ComponentConfig = {+ componentName: "pageTurn",+ importPath: "@/components/remocn/page-turn",+ controls: {+ angle: {+ type: "number",+ default: -7,+ min: -20,+ max: 20,+ step: 1,+ label: "Angle",+ },+ poses: {+ type: "number",+ default: 8,+ min: 2,+ max: 16,+ step: 1,+ label: "Poses",+ },+ },+ durationInFrames: 128,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#f1eee7" },+ snippet: pageTurnExampleCode,+};diff --git a/registry/remocn/page-turn/index.tsx b/registry/remocn/page-turn/index.tsxnew file mode 100644index 00000000..bf9bd0b4--- /dev/null+++ b/registry/remocn/page-turn/index.tsx@@ -0,0 +1,63 @@+"use client";++import type {+ TransitionPresentation,+ TransitionPresentationComponentProps,+} from "@remotion/transitions";+import type React from "react";+import { AbsoluteFill, useVideoConfig } from "remotion";++const LIFT_RATIO = 1.28;++export function pageTurnPose(progress: number, poses: number): number {+ const clamped = Math.min(1, Math.max(0, progress));+ const eased = clamped ** 3;+ if (poses <= 1) return eased >= 1 ? 1 : 0;+ const bucket = Math.min(poses - 1, Math.floor(eased * poses));+ return bucket / (poses - 1);+}++export type PageTurnProps = {+ angle?: number;+ origin?: string;+ poses?: number;+};++const PageTurnPresentation: React.FC<+ TransitionPresentationComponentProps<PageTurnProps>+> = ({+ children,+ presentationProgress,+ presentationDirection,+ passedProps,+}) => {+ const { height } = useVideoConfig();+ const { angle = -7, origin = "18% 100%", poses = 8 } = passedProps;++ if (presentationDirection === "entering") {+ return <AbsoluteFill>{children}</AbsoluteFill>;+ }++ const pose = pageTurnPose(presentationProgress, poses);++ return (+ <AbsoluteFill+ style={{+ zIndex: 2,+ transformOrigin: origin,+ transform: `translateY(${-pose * height * LIFT_RATIO}px) rotate(${angle * pose}deg)`,+ }}+ >+ {children}+ </AbsoluteFill>+ );+};++export function pageTurn(+ props: PageTurnProps = {},+): TransitionPresentation<PageTurnProps> {+ return {+ component: PageTurnPresentation,+ props,+ };+}diff --git a/registry/remocn/polaroid/__tests__/polaroid.test.ts b/registry/remocn/polaroid/__tests__/polaroid.test.tsindex 9021c890..a33afed9 100644--- a/registry/remocn/polaroid/__tests__/polaroid.test.ts+++ b/registry/remocn/polaroid/__tests__/polaroid.test.ts@@ -45,8 +45,10 @@ describe("polaroidGeometry", () => {}});- it("keeps the card taller than it is wide only below the demo ratio", () => {- const g = polaroidGeometry(652);- expect(g.height / 652).toBeCloseTo(427 / 652, 6);+ it("holds the card's own aspect at every width", () => {+ for (const width of [320, 500, 900]) {+ const g = polaroidGeometry(width);+ expect(g.height / width).toBeCloseTo(427 / 652, 6);+ }});});diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex eb738b53..d5c7d89a 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -1373,6 +1373,20 @@}]},+ {+ "name": "page-turn",+ "type": "registry:component",+ "title": "Page Turn",+ "description": "The exiting scene swings up and away like a notebook page in stop-motion poses, staying above the scene it reveals.",+ "dependencies": ["remotion", "@remotion/transitions"],+ "files": [+ {+ "path": "page-turn/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/page-turn.tsx"+ }+ ]+ },{"name": "stop-motion","type": "registry:lib",