import React from 'react'; import { AbsoluteFill, interpolate } from 'remotion'; import type { TransitionPresentation, TransitionPresentationComponentProps } from '@remotion/transitions'; const GlitchPresenter: React.FC>> = ({ children, presentationDirection, presentationProgress, }) => { const isExiting = presentationDirection === 'exiting'; // Subtle intensity — quick spike in the middle const intensity = interpolate(presentationProgress, [0, 0.35, 0.5, 0.65, 1], [0, 0, 1, 0, 0], { extrapolateLeft: 'clamp', extrapolateRight: 'clamp', }); // Very subtle RGB shift (max 5px) const rgbShift = intensity * 5; // Gentle slice displacement (max 8px, only 3 slices) const sliceOffset = intensity * 8; // Crossfade opacity const opacity = isExiting ? interpolate(presentationProgress, [0, 1], [1, 0], { extrapolateRight: 'clamp' }) : interpolate(presentationProgress, [0, 1], [0, 1], { extrapolateRight: 'clamp' }); // Only 3 slices for a subtle effect const slices = Array.from({ length: 3 }, (_, i) => { const yStart = (i / 3) * 100; const yEnd = ((i + 1) / 3) * 100; const xShift = (i === 1 ? 1 : -1) * sliceOffset * intensity; return { yStart, yEnd, xShift }; }); // No glitch visible — just crossfade if (intensity < 0.05) { return ( {children} ); } return ( {/* Sliced content — subtle horizontal shift on middle third only */} {slices.map((slice, i) => (
{children}
))} {/* Very subtle RGB fringe — barely visible */}
); }; export const glitch = (): TransitionPresentation> => { return { component: GlitchPresenter, props: {}, }; };