# Slide to Split Screen

A fullscreen scene that opens into a 60/40 split-screen layout.

Element page: [https://www.remotion.dev/elements/layouts/slide-to-split-screen/](https://www.remotion.dev/elements/layouts/slide-to-split-screen/)

## Installation

Install this Element into a composition of your Remotion project:

```sh
npx remotion elements use https://www.remotion.dev/elements/layouts/slide-to-split-screen/ --composition <composition-id> --yes
```

Replace `<composition-id>` with the ID of the composition to add the Element to. The command installs the dependencies, downloads the assets, writes the source file and adds the Element to the composition. See [`npx remotion elements use`](https://www.remotion.dev/docs/cli/elements/use.md).

## Manual installation

To install the Element manually instead, save the source below as `slide-to-split-screen.element.tsx` in your Remotion project and import its exported component.

## Source

```tsx
import React from 'react';
import {
	Easing,
	Img,
	Interactive,
	interpolate,
	useCurrentFrame,
	useVideoConfig,
} from 'remotion';

const DIVIDER_WIDTH = 15;

const SlideToSplitScreenInner: React.FC = () => {
	const frame = useCurrentFrame();
	const {height, width} = useVideoConfig();
	const bPanelWidth = width * 0.4;
	const aPanelWidth = width - bPanelWidth - DIVIDER_WIDTH;
	const aShift = (width - aPanelWidth) / 2;
	const splitProgress = interpolate(frame, [20, 52, 98, 130], [0, 1, 1, 0], {
		easing: [
			Easing.bezier(0.65, 0, 0.35, 1),
			Easing.linear,
			Easing.bezier(0.65, 0, 0.35, 1),
		],
		extrapolateLeft: 'clamp',
		extrapolateRight: 'clamp',
	});

	return (
		<>
			<div
				style={{
					height,
					left: 0,
					overflow: 'hidden',
					position: 'absolute',
					top: 0,
					width: interpolate(splitProgress, [0, 1], [width, aPanelWidth]),
				}}
			>
				<Interactive.Div
					name="Scene A"
					style={{
						alignItems: 'center',
						color: '#ffffff',
						display: 'flex',
						fontFamily: 'sans-serif',
						fontSize: 240,
						fontWeight: 900,
						height,
						justifyContent: 'center',
						position: 'absolute',
						textShadow: '0 4px 30px rgba(0, 0, 0, 0.55)',
						translate: `${-aShift * splitProgress}px 0px`,
						width,
						willChange: 'transform',
					}}
				>
					<Img
						alt=""
						name="Scene A background"
						src="https://remotion.media/transition-bg-blue.jpg"
						style={{
							height: '100%',
							objectFit: 'cover',
							position: 'absolute',
							width: '100%',
						}}
					/>
					<div style={{position: 'relative'}}>A</div>
				</Interactive.Div>
			</div>

			<div
				style={{
					display: 'flex',
					height,
					position: 'absolute',
					right: 0,
					top: 0,
					translate: `${(1 - splitProgress) * (bPanelWidth + DIVIDER_WIDTH)}px 0px`,
					width: bPanelWidth + DIVIDER_WIDTH,
					willChange: 'transform',
				}}
			>
				<Interactive.Div
					name="Divider"
					style={{
						backgroundColor: '#ffffff',
						flex: `0 0 ${DIVIDER_WIDTH}px`,
						height: '100%',
					}}
				/>
				<Interactive.Div
					name="Scene B"
					style={{
						alignItems: 'center',
						color: '#ffffff',
						display: 'flex',
						fontFamily: 'sans-serif',
						fontSize: 240,
						fontWeight: 900,
						height,
						justifyContent: 'center',
						position: 'relative',
						textShadow: '0 4px 30px rgba(0, 0, 0, 0.55)',
						width: bPanelWidth,
					}}
				>
					<Img
						alt=""
						name="Scene B background"
						src="https://remotion.media/transition-bg-pink.jpg"
						style={{
							height: '100%',
							objectFit: 'cover',
							position: 'absolute',
							width: '100%',
						}}
					/>
					<div style={{position: 'relative'}}>B</div>
				</Interactive.Div>
			</div>
		</>
	);
};

export const SlideToSplitScreen = Interactive.create({
	Component: SlideToSplitScreenInner,
	layout: 'absolute-fill',
});
```

