Before After Wipe 1
A proof or mechanism beat: one subject before and after from the same angle, both in their own colours; a straight seam sweeps across and pauses halfway so both read, then the timeframe lands centred at the top on a short top scrim; mid sales video, VSL or video ad.
Use it in a prompt
Use the video/before-after-wipe video frame from the FunnelDNA library in my brand (landscape and vertical). Follow the video skill. Ask me for the script facts, voice and images you need; do not invent proof.
Paste into Claude or ChatGPT with FunnelDNA connected (MCP setup), or alongside the skill.
Use it in code
- Save
component.tsx(Code tab) ascomponents/funneldna/video/before-after-wipe.tsx. - Import it and pass your copy and images (Props tab):
import { BeforeAfterWipe } from "@/components/funneldna/video/before-after-wipe"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/video/before-after-wipe/component.tsx 208 lines
// When to use: A proof or mechanism beat: one subject before and after from the same angle, both in their own colours; a straight seam sweeps across and pauses halfway so both read, then the timeframe lands centred at the top on a short top scrim; mid sales video, VSL or video ad.
import * as React from "react"
import { Img, useVideoConfig } from "remotion"
import noise from "../fx/textures/noise"
import {
EASE, HOLD, IN_OUT, Rise, SPRINGS, SafeArea, StageField, T, VideoStage, countText, display, ok, progress, springAt, useFitText, useHeld, useStage, useWords,
type VideoFormat, type VideoMeta, type Word,
} from "../fx/video-kit"
export const video = { fps: 30, durationInFrames: 180, formats: ["landscape", "vertical"], poster: 172 } satisfies VideoMeta
export type BeforeAfterWipeProps = {
format?: VideoFormat
durationInFrames?: number
/** The before photo (pass slot("item-1", …)): the same subject, from the same angle, as `after`. Shown in its own colours, never washed. Real or clearly illustrative; never bodies, health or money. */
before?: string
/** The after photo (pass slot("item-2", …)). It stays in its own colours; only the short band behind the headline gets a scrim. */
after?: string
/** The timeframe that lands centred at the top at the end ("11 days apart."); its digits count up from zero. Empty draws no headline. */
headline?: string
/** Optional short sentences under the headline, set on one centred line where they fit. */
support?: string
/** Where the seam pauses so both sides read, as a share of the sweep (0.25–0.75, default half). */
pauseAt?: number
/** Chip over the before side. */
beforeLabel?: string
/** Chip over the after side. */
afterLabel?: string
/** Voice timings for `headline`; its words never land before the seam has finished. */
words?: Word[]
/** Focal point of both photos (CSS object-position). */
focus?: string
}
/** Before to after: hold on the before, the seam sweeps to the pause, holds a beat, finishes; then a short top scrim fades in and the timeframe headline lands centred over the after, which keeps its own colours below it. */
export function BeforeAfterWipe({
format = "landscape",
durationInFrames = video.durationInFrames,
before,
after,
headline = "",
support = "",
pauseAt = 0.5,
beforeLabel = "Before",
afterLabel = "After",
words,
focus = "50% 50%",
}: BeforeAfterWipeProps) {
const f = useHeld(durationInFrames)
const { fps } = useVideoConfig()
const { text, u, width: W, height: H, portrait } = useStage()
const stop = Math.min(0.75, Math.max(0.25, pauseAt))
// The seam: a 20-frame hold on the before, a 20-frame leg to the pause, a beat with a slow creep, a 20-frame finish.
// Short scenes compress the sweep so the headline and its count still land before the final hold.
const k = Math.min(1, Math.max(0.45, (durationInFrames - HOLD - 60) / 88))
const t0 = Math.round(20 * k), t1 = Math.round(40 * k), t2 = Math.round(68 * k), t3 = Math.round(88 * k)
const s = f < t1 ? (stop - CREEP) * progress(f, t0, t1, EASE)
: f < t2 ? stop - CREEP + 2 * CREEP * progress(f, t1, t2, linear)
: stop + CREEP + (1 - stop - CREEP) * progress(f, t2, t3, IN_OUT)
const seamOpacity = progress(f, t0, t0 + 4, linear) * (1 - progress(f, t3 - 4, t3, linear))
// Once the after is whole (the seam gone), a slow push keeps the frame alive into the hold.
const push = 1 + 0.03 * progress(f, t3, durationInFrames - HOLD, IN_OUT)
// The headline: words land as spoken (never before the seam has finished), digits count up from zero.
const hasHead = headline.trim().length > 0
const lines = support.split(/(?<=[.!?])\s+/).map((l) => l.trim()).filter(Boolean)
const hasText = hasHead || lines.length > 0
const n = headline.split(/\s+/).filter(Boolean).length
const hBase = t3 + 8
const raw = useWords(hasHead ? headline : "", hasHead ? words : undefined, durationInFrames, {
from: hBase, span: Math.min(1, (hBase + 4 * Math.max(1, n - 1)) / durationInFrames),
})
const shift = raw.length ? Math.max(0, hBase - raw[0].at) : 0
const latest = durationInFrames - HOLD - 30
const timed = raw.map((x) => ({ ...x, at: Math.min(latest, x.at + shift) }))
const first = timed.length ? timed[0].at : hBase
const lastAt = timed.length ? timed[timed.length - 1].at : hBase
// The top scrim is fully in by the first word, so every frame of the landing holds contrast.
const scrimAt = Math.max(0, first - 16)
const scrimO = hasText ? progress(f, scrimAt, scrimAt + 14, IN_OUT) : 0
// Chips sit low, clear of the headline. Landscape: Before bottom-left, After bottom-right. Vertical (after reveals from
// the top): Before bottom-left, After top-left during the sweep, handing over to the bottom-left once the headline comes.
const chipH = (CHIP.font * 1.2 + 2 * CHIP.v) * u
const chipW = (label: string) => (label.length * 0.62 * CHIP.font + 2 * CHIP.pad) * u
const lowTop = H - text.bottom - 32 * u - chipH
const afterTop = portrait ? text.top : lowTop
const leaveB = portrait ? lowTop / H : 1 - (text.left + chipW(beforeLabel)) / W
const arriveA = portrait ? (afterTop + chipH) / H : (text.right + chipW(afterLabel)) / W
const enter = springAt(f, 2, fps, SPRINGS.firm)
const beforeO = Math.min(1, enter * 1.6) * (1 - clamp01((s - (leaveB - 0.03)) / 0.05))
const handOff = portrait && hasText
const afterO = clamp01((s - arriveA) / 0.05) * (handOff ? 1 - progress(f, scrimAt - 8, scrimAt + 2, linear) : 1)
const settleAt = Math.max(t3 + 2, scrimAt + 2)
const settledO = handOff ? progress(f, settleAt, settleAt + 10, linear) : 0
// Landscape reveals the after from the right edge; vertical reveals it from the top down.
const clip = portrait ? `inset(0 0 ${(1 - s) * 100}% 0)` : `inset(0 0 0 ${(1 - s) * 100}%)`
// A crisp dark contact shadow on both faces of the seam, in stage units through the stage's --u.
const seam: React.CSSProperties = portrait
? {
left: 0, right: 0, top: s * H - 3 * u, height: 6 * u,
boxShadow: "0 calc(var(--u) * -2px) calc(var(--u) * 3px) oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.4), 0 calc(var(--u) * 2px) calc(var(--u) * 3px) oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.4)",
}
: {
top: 0, bottom: 0, left: (1 - s) * W - 3 * u, width: 6 * u,
boxShadow: "calc(var(--u) * -2px) 0 calc(var(--u) * 3px) oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.4), calc(var(--u) * 2px) 0 calc(var(--u) * 3px) oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.4)",
}
// The text block: centred at the top across the full safe width, ~132px in landscape (1–2 rows), ~148px in vertical (2–3 rows).
const colW = W - text.left - text.right
const headMax = (portrait ? 148 : 132) * u
const head = React.useRef<HTMLHeadingElement>(null)
const size = useFitText(head, headline, {
boxW: colW, boxH: (portrait ? 3 : 2) * headMax * 1.08, guess: headMax,
max: headMax, min: (portrait ? 120 : 108) * u, lines: portrait ? [2, 3] : [1, 2],
})
// The short top scrim covers only the text block, then clears well above the photos' subject.
const gap = 24 * u, supSize = (portrait ? 56 : 54) * u
const rowsOf = (str: string, px: number) => Math.min(3, Math.max(1, Math.ceil((str.length * 0.58 * px) / colW)))
const textH = (hasHead ? rowsOf(headline, size) * size * 1.04 : 0) + (hasHead && lines.length ? gap : 0)
+ (lines.length ? rowsOf(lines.join(" "), supSize) * supSize * 1.25 : 0)
const band = (alpha: number) => ok("--band", 0, alpha)
const edge = ((text.top + textH) / H) * 100
const scrimBg = `linear-gradient(180deg, ${band(0.9)} 0%, ${band(0.9)} ${edge + 3}%, ${band(0.5)} ${edge + 7}%, ${band(0)} ${edge + 13}%)`
const parts: React.ReactNode[] = []
timed.forEach((x, i) => {
const sp = springAt(f, x.at, fps, SPRINGS.pop)
const counted = countText(x.w, progress(f, x.at, x.at + 26, EASE))
parts.push(
<span key={x.i} style={{ display: "inline-block", opacity: Math.min(1, sp * 2.5), transform: `translateY(${(1 - sp) * 26 * u}px) scale(${0.94 + 0.06 * sp})` }}>
{/\d/.test(x.w)
? <span style={{ position: "relative", display: "inline-block", fontVariantNumeric: "tabular-nums" }}>
<span style={{ visibility: "hidden" }}>{x.w}</span>
<span style={{ position: "absolute", inset: 0, textAlign: "right" }}>{counted}</span>
</span>
: x.w}
</span>,
)
if (i < timed.length - 1) parts.push(" ")
})
return (
<VideoStage format={format} tone="band">
<StageField tone="band" texture={noise} opacity={0.14} frame={f} />
<div style={{ position: "absolute", inset: 0, zIndex: 1, transform: `scale(${push})`, transformOrigin: focus }}>
{before && <Img src={before} alt={beforeLabel} style={photo(focus)} />}
{after && <Img src={after} alt={afterLabel} style={{ ...photo(focus), clipPath: clip }} />}
</div>
{seamOpacity > 0 && <div aria-hidden style={{ position: "absolute", zIndex: 2, background: T.bandInk, opacity: seamOpacity, ...seam }} />}
{hasText && scrimO > 0 && (
<div aria-hidden style={{ position: "absolute", inset: 0, zIndex: 3, opacity: scrimO, background: scrimBg, pointerEvents: "none" }} />
)}
<Chip label={beforeLabel} bg={T.card} ink={T.ink} u={u} style={{
top: lowTop, left: text.left, opacity: beforeO, transform: `translateY(${(1 - Math.min(1, enter)) * 16 * u}px)`,
}} />
{afterO > 0 && (
<Chip label={afterLabel} bg={T.accentFill} ink={T.accentFillInk} u={u} style={{
top: afterTop, ...(portrait ? { left: text.left } : { right: text.right }), opacity: afterO, transform: `scale(${0.92 + 0.08 * afterO})`,
}} />
)}
{settledO > 0 && (
<Chip label={afterLabel} bg={T.accentFill} ink={T.accentFillInk} u={u} style={{
top: lowTop, left: text.left, opacity: settledO, transform: `scale(${0.92 + 0.08 * settledO})`,
}} />
)}
{hasText && (
<SafeArea style={{ zIndex: 5, justifyContent: "flex-start", alignItems: "center", textAlign: "center", gap }}>
{hasHead && (
<h2 ref={head} style={{ ...display(size, { lineHeight: 1.04 }), position: "relative", margin: 0, color: T.bandInk, maxWidth: colW, textAlign: "center" }}>{parts}</h2>
)}
{lines.length > 0 && (
<div style={{
position: "relative", display: "flex", flexWrap: "wrap", justifyContent: "center", columnGap: supSize * 0.3, maxWidth: colW,
fontFamily: "var(--font-body)", fontWeight: 600, fontSize: supSize, lineHeight: 1.25, color: T.bandInk, textAlign: "center", textWrap: "pretty",
}}>
{lines.map((l, i) => <Rise key={i} at={lastAt + 6 + i * 5} y={20}>{l}</Rise>)}
</div>
)}
</SafeArea>
)}
</VideoStage>
)
}
export default BeforeAfterWipe
const CREEP = 0.012
const CHIP = { font: 44, pad: 32, v: 14 }
const linear = (t: number) => t
const clamp01 = (x: number) => Math.min(1, Math.max(0, x))
const photo = (focus: string): React.CSSProperties => ({ position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: "cover", objectPosition: focus })
/** A solid label chip from tokens, sized in stage px (44px text). */
function Chip({ label, bg, ink, u, style }: { label: string; bg: string; ink: string; u: number; style: React.CSSProperties }) {
return (
<div style={{
position: "absolute", zIndex: 4, display: "flex", alignItems: "center", height: (CHIP.font * 1.2 + 2 * CHIP.v) * u, padding: `0 ${CHIP.pad * u}px`,
borderRadius: 999, background: bg, color: ink, fontFamily: "var(--font-body)", fontWeight: 800, fontSize: CHIP.font * u, lineHeight: 1.2,
letterSpacing: "0.01em", whiteSpace: "nowrap",
boxShadow: "0 calc(var(--u) * 1px) calc(var(--u) * 2px) oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.3), 0 calc(var(--u) * 8px) calc(var(--u) * 16px) calc(var(--u) * -6px) oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.4)",
...style,
}}>{label}</div>
)
}
pieces/video/before-after-wipe/specimen.tsx 37 lines
import __studioImage07348de2 from "../assets/84aba983c852d795.webp";
import __studioImage3f7d1a99 from "../assets/f42af6fbc6e3afd2.webp";
import * as React from "react"
import { slot } from "../../slots"
import { VideoPreview, type VideoFormat } from "../../fx/video-kit"
import { BeforeAfterWipe, video, type BeforeAfterWipeProps } from "../before-after-wipe"
export const states = ["landscape", "vertical"]
/** The before in its own colours with its chip, the seam paused at half with both sides clean, the headline landing centred on its top scrim, the whole after with the headline in the final hold. */
export const keyframes = [16, 54, 120, 175]
const beforeShot = __studioImage07348de2
const afterShot = __studioImage3f7d1a99
// Fictional sample: Brightline Garage Co., a garage wall-system installer.
export const sample: BeforeAfterWipeProps = {
before: beforeShot,
after: afterShot,
headline: "11 days apart.",
support: "Same garage, same angle. Done.",
pauseAt: 0.5,
focus: "50% 55%",
}
/** The sample business in its own colours and type (sample-palettes.md: coral-cobalt · tech); Original and every preset stay one click away. */
export const sampleBrand = { name: "Brightline Garage Co.", theme: "light", background: "#f5f7fc", colors: ["#2c4bdb", "#f0623f"], fonts: ["Space Grotesk", "Manrope"] }
export default function BeforeAfterWipeSpecimen({ state = "landscape" }: { state?: string }) {
return (
<VideoPreview
component={BeforeAfterWipe}
props={{ ...sample, before: slot("item-1", beforeShot), after: slot("item-2", afterShot) }}
format={state as VideoFormat}
meta={video}
/>
)
}
| Name | Type | Details |
|---|---|---|
format OptionalBeforeAfterWipe |
VideoFormat |
Default "landscape"
|
durationInFrames OptionalBeforeAfterWipe |
number |
Default video.durationInFrames
|
before OptionalBeforeAfterWipe |
string |
|
after OptionalBeforeAfterWipe |
string |
|
headline OptionalBeforeAfterWipe |
string |
Default ""
|
support OptionalBeforeAfterWipe |
string |
Default ""
|
pauseAt OptionalBeforeAfterWipe |
number |
Default 0.5
|
beforeLabel OptionalBeforeAfterWipe |
string |
Default "Before"
|
afterLabel OptionalBeforeAfterWipe |
string |
Default "After"
|
words OptionalBeforeAfterWipe |
Word[] |
|
focus OptionalBeforeAfterWipe |
string |
Default "50% 50%"
|
Theme roles it reads
Set by the theme bar, a preset or your brand. Colours come from the base tokens (--surface, --ink, --cta…) every piece uses.
None listed in this pack.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
item-1- One image per offer item (item-1, item-2…), shown in stacks and lists.
item-2- One image per offer item (item-1, item-2…), shown in stacks and lists.
-
84aba983c852d795.webp
image/webp · 78.4 KB
-
bec2a41897a3364d.webp
image/webp · 51.2 KB
-
f42af6fbc6e3afd2.webp
image/webp · 113 KB