UNPKG

@remotion/gif

Version:

Embed GIFs in a Remotion video

47 lines (46 loc) 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Gif = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const remotion_1 = require("remotion"); const GifForDevelopment_1 = require("./GifForDevelopment"); const GifForRendering_1 = require("./GifForRendering"); /* * @description Displays a GIF that synchronizes with Remotions useCurrentFrame(). * @see [Documentation](https://remotion.dev/docs/gif) */ const gifSchema = { playbackRate: { type: 'number', min: 0, max: 10, step: 0.1, default: 1, description: 'Playback Rate', }, ...remotion_1.Internals.sequenceVisualStyleSchema, hidden: remotion_1.Internals.hiddenField, }; const GifInner = ({ src, width, height, onLoad, onError, fit, playbackRate, loopBehavior, id, delayRenderTimeoutInMilliseconds, durationInFrames, style, _experimentalControls: controls, ref, ...sequenceProps }) => { const env = (0, remotion_1.useRemotionEnvironment)(); const { durationInFrames: videoDuration } = (0, remotion_1.useVideoConfig)(); const resolvedDuration = durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : videoDuration; const gifProps = { src, width, height, onLoad, onError, fit, playbackRate, loopBehavior, id, delayRenderTimeoutInMilliseconds, style, }; const inner = env.isRendering ? (jsx_runtime_1.jsx(GifForRendering_1.GifForRendering, { ...gifProps, ref: ref })) : (jsx_runtime_1.jsx(GifForDevelopment_1.GifForDevelopment, { ...gifProps, ref: ref })); return (jsx_runtime_1.jsx(remotion_1.Sequence, { layout: "none", durationInFrames: resolvedDuration, name: "<Gif>", _experimentalControls: controls, ...sequenceProps, children: inner })); }; exports.Gif = remotion_1.Internals.wrapInSchema(GifInner, gifSchema); exports.Gif.displayName = 'Gif'; remotion_1.Internals.addSequenceStackTraces(exports.Gif);