spatial-push
remotionui/spatial-pushFreeComponent
Push where both scenes travel locked edge to edge across the frame
Live preview
live · rendered by the registry
Rendered by remotionui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://remotionui.com/r/spatial-push.jsonSource
1import type { TransitionPresentation } from "@remotion/transitions";2import { useMemo } from "react";3import { AbsoluteFill } from "remotion";4import {5 resolveTransitionTiming,6 transitionPhase,7 type TransitionVariant,8} from "@/remotion/lib/transition-timing";910export type SpatialPushDirection =11 | "from-left"12 | "from-right"13 | "from-top"14 | "from-bottom";1516export type SpatialPushProps = {17 direction?: SpatialPushDirection;18 perspective?: number;19 /**20 * Share of the frame each scene travels, 0→1. Anything below 1 leaves part21 * of the frame uncovered mid-push, so only lower it over a solid backdrop.22 */23 pushDepth?: number;24 /**25 * Degrees each panel rotates away from the camera. Off by default: rotating26 * a full-frame panel in 3D pulls one edge in, and the frame it uncovers is27 * bare background. Raise it only over a backdrop, or with `pushDepth < 1`.28 */29 tilt?: number;30};3132const AXIS: Record<SpatialPushDirection, { axis: "x" | "y"; sign: number }> = {33 "from-left": { axis: "x", sign: -1 },34 "from-right": { axis: "x", sign: 1 },35 "from-top": { axis: "y", sign: -1 },36 "from-bottom": { axis: "y", sign: 1 },37};3839const SpatialPushPresentation: React.FC<40 React.ComponentProps<41 NonNullable<TransitionPresentation<SpatialPushProps>["component"]>42 >43> = ({44 children,45 presentationProgress,46 presentationDirection,47 passedProps: {48 direction = "from-left",49 perspective = 1200,50 pushDepth = 1,51 tilt = 0,52 },53}) => {54 // Both scenes are locked to the same travel across the whole window: a push55 // is one move of two panels, not two independent entrances.56 const phase = transitionPhase(presentationProgress, presentationDirection, {57 lead: 1,58 });5960 const style = useMemo(() => {61 const { axis, sign } = AXIS[direction];62 // A push moves both scenes the same way across the frame: the incoming one63 // arrives from `direction`, the outgoing one is shoved out the far side.64 const travel = sign * (phase.isEntering ? 1 : -1) * phase.displace * pushDepth * 100;65 const rotate = axis === "x" ? "rotateY" : "rotateX";66 const rotateSign = axis === "x" ? 1 : -1;67 const angle = sign * rotateSign * (phase.isEntering ? 1 : -1) * phase.displace * tilt;68 // Overscan only pays for the tilt. Without one the panels are already69 // flush edge to edge, and scaling them would open the seam it closes.70 const scale = tilt === 0 ? 1 : 1 + phase.displace * 0.06;71// … truncated
More from remotionui
All 127 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| audio-pulseaudio-pulse | remotionui | Components | Free | no deps | |
| audiogram-barsaudiogram-bars | remotionui | Components | Free | no deps | |
| blur-focus-inblur-focus-in | remotionui | Components | Free | no deps | |
| blur-inblur-in | remotionui | Components | Free | no deps | |
| blur-revealblur-reveal | remotionui | Components | Free | no deps | |
| caption-highlightcaption-highlight | remotionui | Components | Free | no deps | |
| chromatic-aberration-wipechromatic-aberration-wipe | remotionui | Components | Free | no deps | |
| confetti-burstconfetti-burst | remotionui | Components | Free | no deps |
