mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-03 12:17:03 +00:00
* feat(catalog): add the seven 3D-motion pieces as installable registry blocks Each piece ships as a registry block with a CDN poster and preview, a live catalog detail page and its source. Scripts travel inside the catalog payload (shared vendor libraries fetched once, item scripts inline, the one HDR as a data URI) because the docs host only serves fonts, images and JSON. NO_ESSAY_COMMENTS_OK: the long comment blocks are in vendored libraries and the ported frost source under registry/blocks, not hand-written here. HF_MAX_NONLFS_KB=6000: four hosted texture PNGs under docs/public/catalog/items are runtime assets the docs host must serve as files. fallow skipped locally: it audits against origin/main and this branch is stacked on an older main. * chore(catalog): regenerate gallery data and nav after rebasing onto main * fix(catalog): read the install manifest through the bounded project reader * fix(catalog): a script the inliner missed fails the payload instead of shipping a dead URL * refactor(catalog): the leftover-script check reuses the reference finder * fix(catalog): frost and glass textures load from the CDN and the iteration presets are gone * chore(catalog): regenerate the frost and glass payloads and nav * fix(catalog): frost and glass textures are hosted through the registry url field, not hardcoded * chore(catalog): regenerate the frost and glass payloads against the hosted texture URLs * fix(catalog): the hosted-reference rewrite refuses a bare name it cannot safely replace * ci(catalog): verify changed catalog payloads in headless Chrome and check the docs catalog * feat(catalog): every item page follows the shared layout with a Tune panel and tabs * fix(catalog): let the texture-mask item host its masks so its tile plays live * chore(catalog): regenerate item pages, gallery data and the texture-mask payload * chore(catalog): regenerate item pages after merging main * fix(catalog): declared-only variables get the Tune panel, Code and Docs tabs capped * feat(catalog): give the blend-difference caption a demo scene so its tile plays live * chore(catalog): live payload for the blend-difference caption * perf(catalog): heavy 3d pieces compile and draw before ready, not on the first visible frame * feat(catalog): the avatar promo card hosts its videos, audio and fonts on the CDN * feat(catalog): the avatar promo card tile plays live from its CDN-hosted media * chore(catalog): the avatar promo card plays live, no allowlist left * chore(catalog): shorten two comment blocks * chore(catalog): trim first-party comment blocks to the comment-check limits * chore(catalog): shorten two frost source comments * fix(catalog): the Docs tab renders as prose again, and the detail page honours reduced motion Frame-mode pages carry no prose wrapper, and the detail component sat inside not-prose, so the Docs slot's headings, paragraphs, links and lists had no styling at all. The slots now carry their own prose classes and the chrome around them keeps not-prose. The recorded clip also gets the reduced-motion guard the docs-snippet check requires, and the generator reads stability from the source metadata type so the scripts typecheck passes. * fix(catalog): docs-tab paragraphs render as blocks Mintlify emits paragraphs as inline spans, so two paragraphs in the Docs slot ran together. * fix(ci): drop the duplicate docs_catalog job output git's line-based auto-merge silently duplicated the outputs key when main and this branch each added it on non-adjacent lines during the rebase; oxfmt's yaml parser rejects the repeated map key. * fix(catalog): close four CodeQL alerts in the frost source * chore(catalog): allowlist the avatar-promo-card CDN asset deletions, format sync-docs-catalog check-no-main-deletions.mjs was rejecting 11 local mp4/font files this branch already deleted in favor of CDN hosting; scripts/sync-docs-catalog.mjs had one line over the 100-col print width from an earlier edit in this branch. * fix(catalog): detail tabs use docs prose spacing, Install first; previews skip no-WebGPU runners * fix(catalog): the docs tab scrolls with the page instead of a capped inner box * refactor(catalog): split the payload asset and verify scripts into single-purpose helpers * refactor(catalog): split the preview generator into single-purpose helpers * ci(catalog): fail when the committed catalog differs from generator output The docs host serves the committed catalog and nothing regenerates it, so a stale copy shipped silently. The catalog payloads job now generates into a temp dir and compares it with the committed tree. * chore(catalog): regenerate docs/public/catalog with the refactored scripts One full regeneration from an empty output tree with the current scripts. The tree grows from 58.4 MB to 65.1 MB. Two hosted assets are about 2 MB each (an avatar png and a wav); the same bytes are already committed under assets/, so HF_MAX_NONLFS_KB is raised for this commit only. * fix(catalog): run the catalog script tests under the runner they are written for The rebase put three node:test files in the vitest half of test:scripts, where they report "No test suite found". They now sit in the node --test list. * fix(catalog): a WebGPU item without an adapter shows its recorded clip and says why * ci(catalog): the drift check runs from a committed fetch mirror with no network Generation now serves every font and CDN script fetch from scripts/catalog-fetch-mirror and fails when a fetch is not in it, even if the caller swallowed the error. CATALOG_FETCH_MIRROR=record refreshes the mirror from the live network. The docs_catalog filter also watches packages/core, packages/producer and the mirror, and the 13 re-hashed font files are listed in ALLOWED_DELETIONS. * chore(catalog): clean up the temp font cache and sort the mirror index without a locale * fix(catalog): hide Tune when the clip stands in, time out the adapter request, share one check * fix(catalog): the adapter probe survives a sync throw and a hang; test the clip guard * fix(catalog): keep the adapter probe inside the component, Mintlify evaluates only exports * fix(catalog): run the detail and page generator tests in CI; no Tune flash while probing WebGPU * docs(catalog): credit vendored libraries and make each SKILL.md list what the block installs CREDITS.md names every vendored dependency with its upstream and licence, and flags the two leaf textures whose origin is still to be confirmed. Each SKILL.md Files table now comes from the block manifest and its install and render paths point at compositions/<name>/. A test checks that every path a SKILL.md names is a manifest file that exists. * fix(catalog): a declared WebGPU item passes verify by its manifest tag, not by console wording verify-catalog-payloads forgave a missing adapter only by matching the markup and the message, which library-reported errors and widgets never satisfy. The webgpu tag in the item manifest is now the owner: a tagged item ignores its page and console errors, an untagged one gets no forgiveness, and a marker payload with no html is listed instead of crashing the run. * docs(catalog): correct the credits per block and guard the mount and render paths CREDITS.md states the three.js version and vendored-or-CDN status per block, adds d3-delaunay, Clipper on the CDN and the Google Fonts loads, and lists every texture with no known origin. The SKILL.md test now also checks the mount and render paths against the manifest composition. * test(catalog): read each block manifest once in the SKILL.md file test The two checks shared a copied manifest read, which fallow flagged as a clone with a high score. * fix(catalog): commit the hosted item files a gitignore rule kept out, and check git not the disk The compositions/ and *-ad/ ignore rules matched folder names under docs/public/catalog/items, so 33 hosted fonts, textures and marks were generated but never committed and would 404 on the docs host. The rules now have a negation for that tree and the files are added. The drift check read the checkout, where git-ignored files still exist, so it passed locally and failed only in CI. It now unpacks HEAD with git archive and compares that. * fix(catalog): a tile keeps its poster until the composition has painted * fix(catalog): a tagged WebGPU item forgives only the adapter-absent error, and test the wiring The manifest webgpu tag now decides whether an item may lack an adapter, and the error wording decides which lines are that absence. Any other page or console error on the item, and every failed request, still fails. The per-item decision is one exported function the tests drive, marker payloads are parsed by a tested helper, and the SKILL.md variable counts are checked against their tables (cuboid-carousel said forty-nine for forty). * fix(catalog): the pinned group's posters load eagerly at high priority * fix(catalog): type the tile reveal test so the scripts typecheck passes * fix(catalog): stop the adapter signature matching an unrelated failed adapter request failed to request .*adapter also matched errors about other adapters. It now matches only a request for the WebGPU adapter, so a tagged item cannot hide an unrelated failure behind it. * test(catalog): a tagged item still fails on an error about some other adapter * feat(catalog): the install command sits above the preview, as on the live catalog * fix(catalog): find the install slot through Mintlify's child wrapper * fix(docs): catalog copy buttons keep their size when the label swaps to Copied * refactor(docs): name the shown copy label once in the catalog copy button * fix(docs): primary catalog button keeps a readable label on hover and after copy * fix(docs): inset the catalog tab strip and tab content to match the boxed panels
656 lines
27 KiB
Plaintext
656 lines
27 KiB
Plaintext
---
|
|
title: "Split Tilt Cards"
|
|
description: "Two equal-weight cards arrive from opposite wings with mirrored rotateY book-open tilts under one shared perspective, pill badges spring-pop at each inner edge, and the pair holds with a barely-there phase-opposed idle float. Card bodies are content slots with token skeleton defaults."
|
|
mode: "frame"
|
|
---
|
|
|
|
import { CatalogDetail, CatalogSlot } from "/snippets/catalog-detail.jsx";
|
|
import { InstallCommand } from "/snippets/install-command.jsx";
|
|
|
|
<CatalogDetail
|
|
previewSrc="/public/catalog/components/split-tilt-cards.json"
|
|
compositionId="split-tilt-cards"
|
|
compositionSrc="compositions/components/split-tilt-cards.html"
|
|
title="Split Tilt Cards"
|
|
description="Two equal-weight cards arrive from opposite wings with mirrored rotateY book-open tilts under one shared perspective, pill badges spring-pop at each inner edge, and the pair holds with a barely-there phase-opposed idle float. Card bodies are content slots with token skeleton defaults."
|
|
variables={[{"id":"label_a","type":"string","role":"content","label":"Left label","description":"Mono header on the left card. Blank hides it.","default":"Before"},{"id":"label_b","type":"string","role":"content","label":"Right label","description":"Mono header on the right card. Blank hides it.","default":"After"},{"id":"badge_a","type":"string","role":"content","label":"Left badge","description":"Pill badge that spring-pops at the left card inner edge. Blank disables it.","default":"v1"},{"id":"badge_b","type":"string","role":"content","label":"Right badge","description":"Pill badge that spring-pops at the right card inner edge. Blank disables it.","default":"v2"},{"id":"accent","type":"enum","role":"style","label":"Accent","description":"Right-card tint, right badge, and right ambient glow color.","default":"green","options":[{"value":"green","label":"Green"},{"value":"blue","label":"Blue"},{"value":"violet","label":"Violet"}]},{"id":"exit","type":"enum","role":"timing","label":"Exit","description":"Outgoing transition. None holds the final spread.","default":"none","options":[{"value":"none","label":"None"},{"value":"fade","label":"Fade"},{"value":"up","label":"Up"}]}]}
|
|
meta={{"category":"Motion Scenes","badge":"Stable","codeLines":571}}
|
|
attribution={{"path":"registry/components/split-tilt-cards","tags":["motion-primitive","layout","compare","holdable","book-open","tilt","slots"]}}
|
|
hasCode
|
|
rawUrl="https://raw.githubusercontent.com/heygen-com/hyperframes/main/registry/components/split-tilt-cards/split-tilt-cards.html"
|
|
>
|
|
|
|
<CatalogSlot slot="code">
|
|
|
|
```html split-tilt-cards.html
|
|
<!doctype html>
|
|
<!--
|
|
split-tilt-cards: HyperFrames video primitive (layout / compare / holdable)
|
|
|
|
Concept: two equal-weight cards arrive from opposite wings, each carrying a
|
|
mirrored 3D rotateY book-open tilt (+18deg left, -18deg right) under one
|
|
shared stage perspective, with box-shadows falling outward from the tilt.
|
|
A pill badge spring-pops at each card's inner edge (left then right, the
|
|
one sanctioned overshoot, kept small), then the pair holds with a
|
|
barely-there phase-opposed idle float and settles dead still. Card bodies
|
|
are content slots with token skeleton defaults.
|
|
|
|
Realizes the comparison-split blueprint's signature move as its own unit
|
|
and resolves the blueprint's name collision (Wave J2, J2-10).
|
|
|
|
Slots (see README.md for a worked example):
|
|
- [data-slot="card-a"]: left card body. Replace the children of this
|
|
element in your installed copy. Default: a muted token wireframe.
|
|
- [data-slot="card-b"]: right card body. Same mechanism. Default: an
|
|
accent-tinted version of the wireframe.
|
|
Direct img/video children of a slot are sized to cover the slot area.
|
|
|
|
Variables (declared in data-composition-variables below):
|
|
- label_a (string, default "Before"): mono header on the left card.
|
|
Empty hides it.
|
|
- label_b (string, default "After"): mono header on the right card.
|
|
Empty hides it.
|
|
- badge_a (string, default "v1"): inner-edge pill on the left card.
|
|
Empty disables that badge pop.
|
|
- badge_b (string, default "v2"): inner-edge pill on the right card.
|
|
Empty disables that badge pop.
|
|
- accent (green | blue | violet, default green): right-card tint, right
|
|
badge, and right ambient glow. green maps to --brand, blue to
|
|
--accent, violet to --accent-2.
|
|
- exit (none | fade | up, default none): outgoing transition. none holds
|
|
the final frame (frame roots own transitions; holds end films).
|
|
|
|
Envelope (fixed IN/OUT, elastic HOLD only, never gsap.timeScale()):
|
|
IN = 2.15s: left card lands 0 to 1.1s, right card 0.2 to 1.3s,
|
|
badge A pops at 1.45s, badge B at 1.75s (+0.40s spring)
|
|
HOLD = elastic = max(0, D - (IN + OUT)); whole 2.0s idle-float
|
|
cycles fit inside HOLD minus a 0.30s closing stillness; each
|
|
cycle starts and ends at rest (explicit tweens, no
|
|
repeat/yoyo), left and right phase-opposed
|
|
OUT = 0.50s when exit is fade or up, 0 when exit is none
|
|
If D < IN + OUT, IN and OUT scale down together so IN + OUT == D.
|
|
|
|
Sync points (fixed offsets inside IN, never in elastic HOLD): badge-pop-a
|
|
lands at 1.85s, badge-pop-b at 2.15s.
|
|
|
|
Sound cue: dispatches a bubbling `hf:sfx` CustomEvent with id
|
|
"badge-pop-soft" at each badge landing. This primitive never plays audio.
|
|
|
|
Mount contract: MOUNTABLE SUB-COMPOSITION. The runtime clones only
|
|
<template> contents; #root fills the host box (inset:0, container-type:
|
|
size), has no data-width/data-height, and registers one paused timeline
|
|
under the literal "split-tilt-cards" key (mount flattening strips
|
|
data-composition-id from the live root). Variables come from
|
|
window.__hyperframes.getVariables().
|
|
-->
|
|
<html
|
|
lang="en"
|
|
data-composition-id="split-tilt-cards"
|
|
data-composition-duration="4.5"
|
|
data-composition-variables='[
|
|
{ "id": "label_a", "type": "string", "role": "content", "label": "Left label", "description": "Mono header on the left card. Blank hides it.", "default": "Before" },
|
|
{ "id": "label_b", "type": "string", "role": "content", "label": "Right label", "description": "Mono header on the right card. Blank hides it.", "default": "After" },
|
|
{ "id": "badge_a", "type": "string", "role": "content", "label": "Left badge", "description": "Pill badge that spring-pops at the left card inner edge. Blank disables it.", "default": "v1" },
|
|
{ "id": "badge_b", "type": "string", "role": "content", "label": "Right badge", "description": "Pill badge that spring-pops at the right card inner edge. Blank disables it.", "default": "v2" },
|
|
{ "id": "accent", "type": "enum", "role": "style", "label": "Accent", "description": "Right-card tint, right badge, and right ambient glow color.", "default": "green", "options": [{ "value": "green", "label": "Green" }, { "value": "blue", "label": "Blue" }, { "value": "violet", "label": "Violet" }] },
|
|
{ "id": "exit", "type": "enum", "role": "timing", "label": "Exit", "description": "Outgoing transition. None holds the final spread.", "default": "none", "options": [{ "value": "none", "label": "None" }, { "value": "fade", "label": "Fade" }, { "value": "up", "label": "Up" }] }
|
|
]'
|
|
>
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>Split Tilt Cards</title>
|
|
</head>
|
|
<body>
|
|
<template>
|
|
<div id="root" data-composition-id="split-tilt-cards" data-duration="4.5" data-fps="30">
|
|
<style>
|
|
*,
|
|
*::before,
|
|
*::after {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
/* Root fills the host-owned box. Internal measurements use cqw/cqh
|
|
and every painted color comes from a contract token. */
|
|
#root {
|
|
position: absolute;
|
|
inset: 0;
|
|
container-type: size;
|
|
isolation: isolate;
|
|
overflow: hidden;
|
|
background: var(--bg, #0b1016);
|
|
color: var(--fg, #f8fafc);
|
|
font-family: var(--font-body, Inter, system-ui, sans-serif);
|
|
pointer-events: none;
|
|
}
|
|
|
|
.stc-clip {
|
|
position: absolute;
|
|
inset: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* Two faint ambient side glows: each wing owns a color identity
|
|
across the 50% symmetry axis. Static by design. */
|
|
.stc-clip::before,
|
|
.stc-clip::after {
|
|
content: "";
|
|
position: absolute;
|
|
top: 14cqh;
|
|
width: 52cqw;
|
|
height: 72cqh;
|
|
border-radius: 50%;
|
|
filter: blur(6cqmin);
|
|
pointer-events: none;
|
|
}
|
|
|
|
.stc-clip::before {
|
|
left: 2cqw;
|
|
background: radial-gradient(
|
|
ellipse at 50% 50%,
|
|
color-mix(in srgb, var(--muted, #94a3b8) 11%, transparent) 0%,
|
|
transparent 70%
|
|
);
|
|
}
|
|
|
|
.stc-clip::after {
|
|
right: 2cqw;
|
|
background: radial-gradient(
|
|
ellipse at 50% 50%,
|
|
color-mix(in srgb, var(--stc-accent, #22c55e) 13%, transparent) 0%,
|
|
transparent 70%
|
|
);
|
|
}
|
|
|
|
/* One shared perspective so both tilts converge on the same
|
|
vanishing point; wings and floats preserve 3D so the card
|
|
rotateY reads through their own gsap transforms. */
|
|
.stc-stage {
|
|
position: absolute;
|
|
inset: 0;
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: var(--space-3, 5cqw);
|
|
align-items: center;
|
|
justify-items: center;
|
|
padding: 0 8cqw;
|
|
perspective: 120cqw;
|
|
}
|
|
|
|
/* No opacity (or other grouping property) may ever land on the
|
|
wing/float/stage chain: it forces transform-style flat and
|
|
squashes the card rotateY. Fades ride the cards and the clip. */
|
|
.stc-wing {
|
|
position: relative;
|
|
width: 100%;
|
|
max-width: 38cqw;
|
|
height: 58cqh;
|
|
transform-style: preserve-3d;
|
|
will-change: transform;
|
|
}
|
|
|
|
.stc-float {
|
|
position: absolute;
|
|
inset: 0;
|
|
transform-style: preserve-3d;
|
|
will-change: transform;
|
|
}
|
|
|
|
.stc-card {
|
|
position: absolute;
|
|
inset: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
padding: var(--space-3, 3.6cqh) var(--space-3, 2.4cqw);
|
|
border: 0.16cqw solid var(--border, #334155);
|
|
border-radius: var(--radius, 2.4cqmin);
|
|
background: color-mix(in srgb, var(--surface, #172033) 90%, var(--bg, #0b1016));
|
|
will-change: opacity;
|
|
}
|
|
|
|
/* Static book-open tilts: +18deg left, -18deg right, with the
|
|
box-shadow falling outward from the tilt (left shadow right,
|
|
right shadow left). The tilt is carried, never tweened. */
|
|
.stc-card-a {
|
|
transform: rotateY(18deg);
|
|
box-shadow: 2.4cqw 3cqh 7cqh color-mix(in srgb, var(--bg, #0b1016) 52%, transparent);
|
|
}
|
|
|
|
.stc-card-b {
|
|
transform: rotateY(-18deg);
|
|
border-color: color-mix(
|
|
in srgb,
|
|
var(--stc-accent, #22c55e) 46%,
|
|
var(--border, #334155)
|
|
);
|
|
background: color-mix(in srgb, var(--surface, #172033) 88%, var(--stc-accent, #22c55e));
|
|
box-shadow: -2.4cqw 3cqh 7cqh color-mix(in srgb, var(--bg, #0b1016) 52%, transparent);
|
|
}
|
|
|
|
.stc-label {
|
|
flex: 0 0 auto;
|
|
margin-bottom: var(--space-2, 2.4cqh);
|
|
color: var(--muted, #94a3b8);
|
|
font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
|
|
font-size: min(2.1cqw, 3.4cqh);
|
|
font-weight: 600;
|
|
letter-spacing: 0.12em;
|
|
line-height: 1;
|
|
text-transform: uppercase;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.stc-card-b .stc-label {
|
|
color: color-mix(in srgb, var(--stc-accent, #22c55e) 72%, var(--fg, #f8fafc));
|
|
}
|
|
|
|
.stc-label:empty {
|
|
display: none;
|
|
}
|
|
|
|
.stc-slot {
|
|
position: relative;
|
|
flex: 1 1 auto;
|
|
min-height: 0;
|
|
overflow: hidden;
|
|
border-radius: calc(var(--radius, 2.4cqmin) * 0.6);
|
|
}
|
|
|
|
/* Caller-supplied media covers its slot edge to edge. */
|
|
.stc-slot > img,
|
|
.stc-slot > video {
|
|
position: absolute;
|
|
inset: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
|
|
/* Token-styled default slot content: a wireframe that reads muted
|
|
on the left card and accent-tinted on the right. Callers
|
|
replacing slot children never see any of this. */
|
|
.stc-default {
|
|
position: absolute;
|
|
inset: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
padding: var(--space-2, 2cqh) var(--space-1, 1cqw);
|
|
}
|
|
|
|
.stc-bar {
|
|
width: 42%;
|
|
height: 4cqh;
|
|
margin-bottom: var(--space-2, 2.6cqh);
|
|
border-radius: 1.2cqh;
|
|
background: var(--muted, #94a3b8);
|
|
opacity: 0.5;
|
|
}
|
|
|
|
.stc-line {
|
|
height: 2.2cqh;
|
|
margin-bottom: var(--space-1, 1.8cqh);
|
|
border-radius: 1.1cqh;
|
|
background: var(--muted, #94a3b8);
|
|
opacity: 0.38;
|
|
}
|
|
|
|
.stc-line:nth-of-type(2) {
|
|
width: 88%;
|
|
}
|
|
|
|
.stc-line:nth-of-type(3) {
|
|
width: 64%;
|
|
}
|
|
|
|
.stc-line:nth-of-type(4) {
|
|
width: 42%;
|
|
}
|
|
|
|
.stc-card-b .stc-bar {
|
|
background: var(--stc-accent, #22c55e);
|
|
opacity: 0.9;
|
|
}
|
|
|
|
.stc-card-b .stc-line {
|
|
background: color-mix(in srgb, var(--stc-accent, #22c55e) 62%, var(--fg, #f8fafc));
|
|
opacity: 0.66;
|
|
}
|
|
|
|
/* Badge positioners own the inner-edge placement (CSS translate);
|
|
gsap scales only the inner pill, so the two transforms never
|
|
collide on one element. */
|
|
.stc-badge-pos {
|
|
position: absolute;
|
|
top: 50%;
|
|
z-index: 3;
|
|
display: flex;
|
|
}
|
|
|
|
.stc-badge-pos-a {
|
|
right: 0;
|
|
transform: translate(32%, -50%);
|
|
}
|
|
|
|
.stc-badge-pos-b {
|
|
left: 0;
|
|
transform: translate(-32%, -50%);
|
|
}
|
|
|
|
.stc-badge {
|
|
padding: var(--space-1, 1.4cqh) var(--space-2, 1.8cqw);
|
|
border: 0.16cqw solid var(--border, #334155);
|
|
border-radius: 999cqw;
|
|
background: color-mix(in srgb, var(--surface, #172033) 82%, var(--bg, #0b1016));
|
|
color: var(--fg, #f8fafc);
|
|
font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
|
|
font-size: min(2.2cqw, 3.6cqh);
|
|
font-weight: 600;
|
|
letter-spacing: 0.04em;
|
|
line-height: 1;
|
|
white-space: nowrap;
|
|
will-change: transform, opacity;
|
|
}
|
|
|
|
.stc-badge-b {
|
|
border-color: color-mix(
|
|
in srgb,
|
|
var(--stc-accent, #22c55e) 62%,
|
|
var(--border, #334155)
|
|
);
|
|
background: color-mix(in srgb, var(--stc-accent, #22c55e) 26%, var(--surface, #172033));
|
|
}
|
|
</style>
|
|
|
|
<div
|
|
id="split-tilt-cards-clip"
|
|
class="stc-clip clip"
|
|
data-start="0"
|
|
data-duration="4.5"
|
|
data-track-index="0"
|
|
>
|
|
<div class="stc-stage">
|
|
<div class="stc-wing stc-wing-a">
|
|
<div class="stc-float stc-float-a">
|
|
<section class="stc-card stc-card-a" aria-label="Left card">
|
|
<div class="stc-label stc-label-a"></div>
|
|
<div class="stc-slot" data-slot="card-a">
|
|
<!-- SLOT "card-a": replace the children of this element
|
|
with your own content (img, video, or HTML). -->
|
|
<div class="stc-default" aria-hidden="true">
|
|
<div class="stc-bar"></div>
|
|
<div class="stc-line"></div>
|
|
<div class="stc-line"></div>
|
|
<div class="stc-line"></div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<div class="stc-badge-pos stc-badge-pos-a">
|
|
<div class="stc-badge stc-badge-a"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="stc-wing stc-wing-b">
|
|
<div class="stc-float stc-float-b">
|
|
<section class="stc-card stc-card-b" aria-label="Right card">
|
|
<div class="stc-label stc-label-b"></div>
|
|
<div class="stc-slot" data-slot="card-b">
|
|
<!-- SLOT "card-b": replace the children of this element
|
|
with your own content (img, video, or HTML). -->
|
|
<div class="stc-default" aria-hidden="true">
|
|
<div class="stc-bar"></div>
|
|
<div class="stc-line"></div>
|
|
<div class="stc-line"></div>
|
|
<div class="stc-line"></div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<div class="stc-badge-pos stc-badge-pos-b">
|
|
<div class="stc-badge stc-badge-b"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
|
|
<script>
|
|
(function () {
|
|
"use strict";
|
|
|
|
var root = document.getElementById("root");
|
|
// Literal id: mount flattening strips data-composition-id from the
|
|
// live root before this timeline registers.
|
|
var compositionId = "split-tilt-cards";
|
|
var clip = root.querySelector(".stc-clip");
|
|
var wingA = root.querySelector(".stc-wing-a");
|
|
var cardA = root.querySelector(".stc-card-a");
|
|
var cardB = root.querySelector(".stc-card-b");
|
|
var wingB = root.querySelector(".stc-wing-b");
|
|
var floatA = root.querySelector(".stc-float-a");
|
|
var floatB = root.querySelector(".stc-float-b");
|
|
var labelA = root.querySelector(".stc-label-a");
|
|
var labelB = root.querySelector(".stc-label-b");
|
|
var badgeA = root.querySelector(".stc-badge-a");
|
|
var badgeB = root.querySelector(".stc-badge-b");
|
|
var badgePosA = root.querySelector(".stc-badge-pos-a");
|
|
var badgePosB = root.querySelector(".stc-badge-pos-b");
|
|
|
|
var vars =
|
|
window.__hyperframes && window.__hyperframes.getVariables
|
|
? window.__hyperframes.getVariables()
|
|
: {};
|
|
|
|
var labelAText = vars.label_a == null ? "Before" : String(vars.label_a);
|
|
var labelBText = vars.label_b == null ? "After" : String(vars.label_b);
|
|
var badgeAText = vars.badge_a == null ? "v1" : String(vars.badge_a);
|
|
var badgeBText = vars.badge_b == null ? "v2" : String(vars.badge_b);
|
|
// Each enum choice routes to a DIFFERENT contract token so the
|
|
// variable stays meaningful under a theme.
|
|
var accentColors = {
|
|
green: "var(--brand, #22c55e)",
|
|
blue: "var(--accent, #38bdf8)",
|
|
violet: "var(--accent-2, #c5a3ff)",
|
|
};
|
|
var accent = Object.prototype.hasOwnProperty.call(accentColors, vars.accent)
|
|
? vars.accent
|
|
: "green";
|
|
// INVARIANT: only none | fade | up reaches the timeline.
|
|
var exit = vars.exit === "fade" || vars.exit === "up" ? vars.exit : "none";
|
|
|
|
labelA.textContent = labelAText;
|
|
labelB.textContent = labelBText;
|
|
badgeA.textContent = badgeAText;
|
|
badgeB.textContent = badgeBText;
|
|
if (badgeAText === "") badgePosA.style.display = "none";
|
|
if (badgeBText === "") badgePosB.style.display = "none";
|
|
root.style.setProperty("--stc-accent", accentColors[accent]);
|
|
|
|
// RETIME RANGE: fixed IN and OUT scale together only when D is too
|
|
// short. HOLD is the sole elastic phase. Never use timeScale().
|
|
var CARD_DUR_BASE = 1.1;
|
|
var CARD_B_DELAY_BASE = 0.2;
|
|
var FADE_DUR_BASE = 0.5;
|
|
var BADGE_A_AT_BASE = 1.45;
|
|
var BADGE_B_AT_BASE = 1.75;
|
|
var BADGE_DUR_BASE = 0.4;
|
|
var IN_BASE = BADGE_B_AT_BASE + BADGE_DUR_BASE;
|
|
var OUT_BASE = exit === "none" ? 0 : 0.5;
|
|
var STILLNESS = 0.3;
|
|
var FLOAT_CYCLE = 2.0;
|
|
|
|
var duration = Math.max(0.001, parseFloat(root.dataset.duration || "4.5"));
|
|
var totalBase = IN_BASE + OUT_BASE;
|
|
var scale = duration < totalBase ? duration / totalBase : 1;
|
|
var IN = IN_BASE * scale;
|
|
var OUT = OUT_BASE * scale;
|
|
var HOLD = Math.max(0, duration - (IN + OUT));
|
|
var OUT_START = IN + HOLD;
|
|
|
|
function fireSfx(id, t) {
|
|
root.dispatchEvent(
|
|
new CustomEvent("hf:sfx", { detail: { id: id, t: t }, bubbles: true }),
|
|
);
|
|
}
|
|
|
|
// Explicit both-endpoints state makes tl.seek(0) deterministic.
|
|
// Fades ride the cards and the clip, never the wing/float/stage
|
|
// chain: opacity there would flatten the 3D tilt.
|
|
gsap.set(clip, { opacity: 1, y: 0 });
|
|
gsap.set(wingA, { x: "-26cqw", scale: 0.85 });
|
|
gsap.set(wingB, { x: "26cqw", scale: 0.85 });
|
|
gsap.set([cardA, cardB], { opacity: 0 });
|
|
gsap.set([floatA, floatB], { y: "0cqh" });
|
|
gsap.set([badgeA, badgeB], { opacity: 0, scale: 0 });
|
|
|
|
var tl = gsap.timeline({ paused: true });
|
|
|
|
// IN: mirrored opposite-wing entries, right ~0.2s behind, each
|
|
// carrying its static book-open tilt; only x/scale/opacity move.
|
|
[
|
|
{ wing: wingA, card: cardA, at: 0 },
|
|
{ wing: wingB, card: cardB, at: CARD_B_DELAY_BASE * scale },
|
|
].forEach(function (entry) {
|
|
tl.to(
|
|
entry.card,
|
|
{ opacity: 1, duration: 0.5 * scale, ease: "power2.out" },
|
|
entry.at,
|
|
);
|
|
tl.to(
|
|
entry.wing,
|
|
{ x: "0cqw", duration: CARD_DUR_BASE * scale, ease: "power3.out" },
|
|
entry.at,
|
|
);
|
|
tl.to(
|
|
entry.wing,
|
|
{ scale: 1, duration: CARD_DUR_BASE * scale, ease: "power3.out" },
|
|
entry.at,
|
|
);
|
|
});
|
|
|
|
// Badges: the one sanctioned overshoot, kept small. Left lands
|
|
// first, right ~0.3s behind, both inside fixed IN.
|
|
[
|
|
{ badge: badgeA, text: badgeAText, at: BADGE_A_AT_BASE * scale },
|
|
{ badge: badgeB, text: badgeBText, at: BADGE_B_AT_BASE * scale },
|
|
].forEach(function (pop) {
|
|
if (pop.text === "") return;
|
|
tl.to(
|
|
pop.badge,
|
|
{ opacity: 1, scale: 1, duration: BADGE_DUR_BASE * scale, ease: "back.out(1.9)" },
|
|
pop.at,
|
|
);
|
|
var land = pop.at + BADGE_DUR_BASE * scale;
|
|
tl.call(
|
|
function () {
|
|
fireSfx("badge-pop-soft", land);
|
|
},
|
|
[],
|
|
land,
|
|
);
|
|
});
|
|
|
|
// HOLD: phase-opposed barely-there idle float. Only whole cycles
|
|
// fit; each is authored as explicit half-cycle tweens (never
|
|
// repeat/yoyo) so every cycle starts and ends at rest, and the
|
|
// closing STILLNESS window stays dead still.
|
|
var floatWindow = Math.max(0, HOLD - STILLNESS);
|
|
var cycles = Math.floor(floatWindow / FLOAT_CYCLE);
|
|
var half = FLOAT_CYCLE / 2;
|
|
for (var i = 0; i < cycles; i += 1) {
|
|
var t0 = IN + i * FLOAT_CYCLE;
|
|
tl.to(floatA, { y: "-0.6cqh", duration: half, ease: "sine.inOut" }, t0);
|
|
tl.to(floatA, { y: "0cqh", duration: half, ease: "sine.inOut" }, t0 + half);
|
|
tl.to(floatB, { y: "0.6cqh", duration: half, ease: "sine.inOut" }, t0);
|
|
tl.to(floatB, { y: "0cqh", duration: half, ease: "sine.inOut" }, t0 + half);
|
|
}
|
|
|
|
// OUT: only when the exit variable asks for one; exit none holds
|
|
// the final spread (frame roots own transitions).
|
|
if (exit !== "none") {
|
|
tl.to(
|
|
clip,
|
|
{ opacity: 0, duration: FADE_DUR_BASE * scale, ease: "power2.in" },
|
|
OUT_START,
|
|
);
|
|
if (exit === "up") {
|
|
tl.to(
|
|
clip,
|
|
{ y: "-6cqh", duration: FADE_DUR_BASE * scale, ease: "power2.in" },
|
|
OUT_START,
|
|
);
|
|
}
|
|
}
|
|
|
|
tl.seek(0);
|
|
|
|
window.__timelines = window.__timelines || {};
|
|
window.__timelines[compositionId] = tl;
|
|
})();
|
|
</script>
|
|
</div>
|
|
</template>
|
|
</body>
|
|
</html>
|
|
```
|
|
|
|
</CatalogSlot>
|
|
|
|
<CatalogSlot slot="install">
|
|
|
|
<InstallCommand command="npx hyperframes add split-tilt-cards" item="split-tilt-cards" />
|
|
|
|
That writes one file: `compositions/components/split-tilt-cards.html`.
|
|
|
|
</CatalogSlot>
|
|
|
|
<CatalogSlot slot="docs">
|
|
|
|
## Paste it into your composition
|
|
|
|
Open `compositions/components/split-tilt-cards.html` and copy what is inside into your own composition.
|
|
|
|
A component has no size or duration of its own. It takes both from the composition
|
|
you paste it into.
|
|
|
|
## Variables
|
|
|
|
Every one of these has a default, so the piece works untouched. Set the ones you
|
|
want to change on the element:
|
|
|
|
| Variable | Default | Accepts | What it does |
|
|
| --- | --- | --- | --- |
|
|
| `label_a` | `Before` | string | Mono header on the left card. Blank hides it. |
|
|
| `label_b` | `After` | string | Mono header on the right card. Blank hides it. |
|
|
| `badge_a` | `v1` | string | Pill badge that spring-pops at the left card inner edge. Blank disables it. |
|
|
| `badge_b` | `v2` | string | Pill badge that spring-pops at the right card inner edge. Blank disables it. |
|
|
| `accent` | `green` | `green`, `blue`, `violet` | Right-card tint, right badge, and right ambient glow color. |
|
|
| `exit` | `none` | `none`, `fade`, `up` | Outgoing transition. None holds the final spread. |
|
|
|
|
Set them with `data-variable-values` on the element that mounts it. These are the
|
|
defaults, so this behaves exactly like the preview above until you change one:
|
|
|
|
```html wrap
|
|
<div
|
|
data-composition-id="split-tilt-cards"
|
|
data-composition-src="compositions/components/split-tilt-cards.html"
|
|
data-variable-values='{"label_a":"Before","label_b":"After","badge_a":"v1","badge_b":"v2","accent":"green","exit":"none"}'
|
|
></div>
|
|
```
|
|
|
|
{/* hf:generated-footer */}
|
|
|
|
Tagged `motion-primitive` `layout` `compare` `holdable` `book-open` `tilt` `slots`.
|
|
|
|
## Related topics
|
|
|
|
- [Browse the complete Catalog](/catalog)
|
|
- [Add assets and Catalog items in Studio](/studio/assets-and-blocks)
|
|
- [Build a richer composition](/go-further)
|
|
|
|
</CatalogSlot>
|
|
|
|
</CatalogDetail>
|