Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

7.5 KB
Raw Blame
{
  "type": "remotion-element",
  "version": 1,
  "element": {
    "assets": [],
    "dependencies": [],
    "dimensions": {
      "width": 720,
      "height": 100
    },
    "displayName": "Blur Out Up",
    "initialProps": null,
    "slug": "blur-out-up",
    "sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface BlurOutUpProps {\n  text: string;\n  staggerDelay?: number;\n  fontSize?: number;\n  color?: string;\n  fontWeight?: number;\n  speed?: number;\n  className?: string;\n}\n\nfunction BlurOutUpBase({\n  text,\n  staggerDelay = 1,\n  fontSize = 72,\n  color = \"#171717\",\n  fontWeight = 600,\n  speed = 1,\n  className,\n}: BlurOutUpProps) {\n  const frame = useCurrentFrame() * speed;\n  const { durationInFrames } = useVideoConfig();\n\n  const words = text.split(\" \");\n\n  const enterDur = 17;\n  const enterTravel = 6;\n  const exitDur = 14;\n  const exitTravelFrom = 8;\n\n  const enterEasing = Easing.bezier(0.22, 1, 0.36, 1);\n  const exitEasing = Easing.bezier(0.64, 0, 0.78, 0);\n\n  const enterEnd = enterDur + (words.length - 1) * staggerDelay;\n  const exitStart = Math.max(\n    enterEnd,\n    durationInFrames - exitDur - (words.length - 1) * staggerDelay,\n  );\n\n  return (\n    <div\n      style={{\n        position: \"absolute\",\n        inset: 0,\n        display: \"flex\",\n        alignItems: \"center\",\n        justifyContent: \"center\",\n        background: \"transparent\",\n      }}\n    >\n      <span\n        className={className}\n        style={{\n          fontSize,\n          fontWeight,\n          color,\n          letterSpacing: \"-0.03em\",\n          fontFamily:\n            \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n        }}\n      >\n        {words.map((word, i) => {\n          const enterLocal = frame - i * staggerDelay;\n          const exitLocal = frame - exitStart - i * staggerDelay;\n\n          const enterP = interpolate(enterLocal, [0, enterDur], [0, 1], {\n            extrapolateLeft: \"clamp\",\n            extrapolateRight: \"clamp\",\n            easing: enterEasing,\n          });\n\n          const exitP = interpolate(exitLocal, [0, exitDur], [0, 1], {\n            extrapolateLeft: \"clamp\",\n            extrapolateRight: \"clamp\",\n            easing: exitEasing,\n          });\n\n          const opacity = enterP * (1 - exitP);\n\n          const yEnter = interpolate(enterLocal, [0, enterTravel], [10, 0], {\n            extrapolateLeft: \"clamp\",\n            extrapolateRight: \"clamp\",\n            easing: enterEasing,\n          });\n\n          const yExit = interpolate(\n            exitLocal,\n            [exitTravelFrom, exitDur],\n            [0, -14],\n            {\n              extrapolateLeft: \"clamp\",\n              extrapolateRight: \"clamp\",\n              easing: exitEasing,\n            },\n          );\n\n          const y = yEnter + yExit;\n\n          const blurEnter = interpolate(enterLocal, [0, enterDur], [6, 0], {\n            extrapolateLeft: \"clamp\",\n            extrapolateRight: \"clamp\",\n            easing: enterEasing,\n          });\n\n          const blurExit = interpolate(exitLocal, [0, exitDur], [0, 8], {\n            extrapolateLeft: \"clamp\",\n            extrapolateRight: \"clamp\",\n            easing: exitEasing,\n          });\n\n          const blur = blurEnter + blurExit;\n\n          return (\n            <span\n              key={i}\n              style={{\n                display: \"inline-block\",\n                marginRight: \"0.25em\",\n                transformOrigin: \"50% 55%\",\n                opacity,\n                translate: `0 ${y}px`,\n                filter: `blur(${blur}px)`,\n              }}\n            >\n              {word}\n            </span>\n          );\n        })}\n      </span>\n    </div>\n  );\n}\n\nconst elementSchema = {\n  ...Interactive.baseSchema,\n  text: {\n    type: \"text-content\",\n    default: \"Clear in, airy out.\",\n    description: \"Text\",\n  },\n  staggerDelay: {\n    type: \"number\",\n    min: 0,\n    max: 8,\n    step: 1,\n    default: 1,\n    description: \"Stagger\",\n    hiddenFromList: false,\n  },\n  fontSize: {\n    type: \"number\",\n    min: 12,\n    max: 160,\n    step: 1,\n    default: 72,\n    description: \"Font size\",\n    hiddenFromList: false,\n  },\n  color: {\n    type: \"color\",\n    default: \"#171717\",\n    description: \"Color\",\n  },\n  fontWeight: {\n    type: \"enum\",\n    default: \"600\",\n    variants: {\n      \"400\": {},\n      \"500\": {},\n      \"600\": {},\n      \"700\": {},\n    },\n    description: \"Font weight\",\n  },\n  speed: {\n    type: \"number\",\n    default: 1,\n    min: 0.25,\n    max: 4,\n    step: 0.25,\n    description: \"Speed\",\n    hiddenFromList: false,\n  },\n  width: {\n    type: \"number\",\n    default: 720,\n    min: 10,\n    step: 10,\n    description: \"Width\",\n  },\n  height: {\n    type: \"number\",\n    default: 100,\n    min: 10,\n    step: 10,\n    description: \"Height\",\n  },\n  ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"staggerDelay\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n  text: \"Clear in, airy out.\",\n  staggerDelay: 1,\n  fontSize: 72,\n  color: \"#171717\",\n  fontWeight: \"600\",\n  speed: 1,\n};\n\ntype BlurOutUpElementProps = InteractiveBaseProps &\n  InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n  ComponentProps<typeof BlurOutUpBase>;\n\nconst BlurOutUpInner = forwardRef<\n  HTMLDivElement,\n  BlurOutUpElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 720, height = 100, ...rest }, ref) => {\n  const outlineRef = useRef<HTMLDivElement>(null);\n  useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n  const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n  const sequenceProps: Record<string, unknown> = {};\n  for (const [key, value] of Object.entries(rest)) {\n    if (ELEMENT_PROP_KEYS.has(key)) {\n      if (value !== undefined) componentProps[key] = value;\n    } else {\n      sequenceProps[key] = value;\n    }\n  }\n  return (\n    <Sequence\n      layout=\"none\"\n      {...sequenceProps}\n      controls={controls}\n      name={name ?? \"<BlurOutUp>\"}\n      outlineRef={outlineRef}\n    >\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          display: \"flex\",\n          alignItems: \"center\",\n          justifyContent: \"center\",\n        }}\n      >\n        <div\n          ref={outlineRef}\n          style={{\n            position: \"relative\",\n            width,\n            height,\n            ...style,\n          }}\n        >\n          <BlurOutUpBase\n            {...(componentProps as unknown as ComponentProps<typeof BlurOutUpBase>)}\n          />\n        </div>\n      </div>\n    </Sequence>\n  );\n});\n\nexport const BlurOutUp = Interactive.withSchema({\n  Component: BlurOutUpInner,\n  componentName: \"<BlurOutUp>\",\n  componentIdentity: null,\n  schema: elementSchema,\n  supportsEffects: false,\n});\n",
    "durationInFrames": 90,
    "installationMode": "component-owned-sequence"
  },
  "durationInFrames": 90
}