Files
hyperframes/docs/catalog/components/pull-to-refresh.mdx
Miguel ÁngelandMiguel Angel Simon Sierra 1ae2067b8d feat(catalog): put the variables panel back, on payloads (#3199)
* feat(catalog): put the variables panel back, on payloads

The panel drove its preview by loading an .html from docs/public, a type the
host does not publish, so it showed an empty frame in production and was
parked when the catalog was re-landed.

It now mounts the same JSON payload the plain player uses and re-mounts it as
values change, injecting them as window.__hfVariables into the composition head
before any of its scripts run, which is where the runtime reads overrides from.
Doing it in the markup rather than after load is what stops the composition
initialising with the wrong values first.

172 items with variables get the panel back; the playhead carries across a
change so a tweak mid-shot does not jump back to frame zero.

* fix(docs): drop the unused url form and the needless escapes

* fix(docs): the panel cannot reference a binding beside the export

* feat(catalog): make importing an SVG the obvious move

A reader arrives at this control with a shape, not with path data, and the
panel asked for the coordinates first. Import is now the primary action in a
drop target you can see is a drop target, and the raw path sits behind a
disclosure for anyone who wants it.

* feat(cli): let a fruitless catalog search report the gap

An agent that searches by meaning and finds nothing worth installing knows
something we do not: the name of a move the catalog is missing. There was no
way to tell us, so that knowledge was lost at the end of every run.

hyperframes feedback --search-miss "<query>" --wanted "<the move>" records it.
It carries no rating, so it never lands in the rating metric, and it is a
separate deliberate command rather than something catalog --query does on its
own: plain search still sends nothing, which is what the CLI promises.

--rating stops being required at the arg level, since a miss has no rating to
give. The check moved into the run body, where an absent one is now handled
rather than crashing on undefined.

* feat(cli): carry tuned variable values into the install snippet

Someone who tunes a block on its catalog page had no way to keep those values:
the install command was the same one everybody gets, and the tuning stayed on
the page.

hyperframes add <item> --vars '<json>' now prints a mount element carrying
data-variable-values, so the values land where the block is used.

They ride on the host rather than being written into the installed file. That
keeps the composition on disk byte-identical to the registry's, so a later
reinstall can still tell an edit from an update, and it lets two mounts of the
same block carry different values.

* fix(catalog): serve the item's own directory so runtime paths resolve

Some compositions assemble their asset URLs at run time —
"compositions/components/" + texture + ".png" for the texture masks, a font the
compiler pulled into _remote_media — and no scan of the markup can see a string
that does not exist until a script concatenates it. Those items either rendered
black or were dropped to a video that had never been uploaded.

Each item that needs it now has its prepared directory published, and its
payload carries a <base> pointing at it, so any relative path the composition
invents resolves. caption-texture renders its masks again, and
variable-font-flex has a preview at all for the first time: its MP4 and poster
are both 403.

Both layouts are published, because which one a composition asks for differs
per item, and a directory only earns that if it is under 2 MB. The 12 MB
texture sheet keeps the recorded video it already had.

* fix(catalog): let the variables panel actually drive the composition

Every control on the panel was inert. The values reached the composition and
nothing repainted, because the payload had already been compiled: compiling
inlines a mounted component and resolves its variables into the markup and CSS,
so by the time a reader turns a knob there is nothing left to change.

An item that declares variables now ships uncompiled, keeping the mount the
runtime loads at run time, which is the only state where data-variable-values
still means anything. The component travels inline as a data URI rather than a
sibling file, because .html is the one type the docs host will not publish. The
demo's own pinned values come off, so the reader's choices reach the mount
instead of losing to the values the demo picked to show itself off.

Measured on the rendered frame rather than the DOM: green rgb(98,207,144),
blue rgb(6,6,199), violet rgb(177,147,230), and back to green.

docs/public/catalog drops from 48 MB to 35 MB along the way, since an
uncompiled payload carries far less than an inlined one.

* feat(catalog): keep variable changes in the url

A reader who tuned a piece lost it on reload, and had nothing to send anyone.
The values now live in the query string, scoped by composition id so two links
never read each other,and only the ones that differ from the defaults are
written, so changing one knob gives a short URL rather than every variable
spelled out.

replaceState rather than pushState: dragging a slider should not leave a trail
of history entries. An unreadable value is ignored rather than thrown, so a
truncated or hand-edited link opens the piece at its defaults.

* fix(catalog): only rewrite the url when a value actually changed

* refactor(catalog): memoise the declared defaults on their content

* feat(catalog): offer an install command carrying the tuned values

The Install block is generated before anyone touches a knob, so it can only
ever print the plain command. Someone who spent a minute tuning a piece copied
it and got the defaults back.

The panel now carries its own command in the Snippet tab, with --vars holding
exactly the values that differ. An untouched piece still offers the same short
command, so nothing gets noisier for the common case.

* fix(catalog): a piece with nothing to render is a skip, not a failure

caption-blend-difference is a stylesheet and a paragraph of prose — a class you
add to your own captions, with no standalone scene to show. The generator
treated that as a build failure, so every run ended by reporting something
broken when nothing was.

It now reports the shape it is and keeps its recorded video, which is the only
honest preview such an item has. A genuine render failure still throws.

* fix(catalog): restore variables from the url on a cold load

A shared link opened at the defaults. The first render happens on the server,
where there is no window to read the query string from, and React then hydrates
against that markup and never revisits it — so the values only appeared once you
touched a control.

The URL is read again after mount, which is the first moment it exists. The
value is also escaped once now rather than twice: URLSearchParams already
decodes on the way out, and decoding a second time turned an SVG path full of
percent-escapes into something that no longer parsed, besides doubling the
length of every link.

* fix(catalog): mount the preview with the values a link carried

The frame was built from the declared defaults and the shared values were
posted to it afterwards, which is too late for anything the composition reads
once at init: a path arrived after the mark had already been drawn from the
default one, so a link looked right in the panel and wrong on screen.

* feat(catalog): the install command follows the values you tuned

Copying the Install line gave the plain command back, because that block is
generated before anyone touches a knob and had no way to know what changed. The
tuned command only existed in the panel Snippet tab, which is not where anyone
looks for it.

The line now reads the same query string the panel writes, so the two agree
without either component knowing the other exists, and a shared link carries the
right command too. replaceState fires no event, so the panel announces its own
writes.

* fix(catalog): send a text variable to the preview once it is finished

Every other control in the explorer reports a whole value on every event: a
slider at any position is a position, a swatch is a colour. A text field is
not. Typing v3 into a badge posted v first, so the preview remounted and
rendered a composition built from half a word.

The post now waits while a text field has focus and goes out when the edit is
committed, with Enter or by clicking away. The field itself is unchanged and
still tracks every keystroke.

---------

Co-authored-by: Miguel Angel Simon Sierra <miguelangelsi07@gmail.com>
2026-08-10 22:40:01 -04:00

1431 lines
53 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Pull to Refresh"
description: "A mobile list pulls through nonlinear rubber-band resistance, arms at a threshold, commits to a bounded loading indicator, then snaps exactly back to rest."
---
import { InstallCommand } from "/snippets/install-command.jsx";
import { VariablesExplorer } from "/snippets/variables-explorer.jsx";
<VariablesExplorer
previewSrc="/public/catalog/components/pull-to-refresh.json"
compositionId="pull-to-refresh"
compositionSrc="compositions/components/pull-to-refresh.html"
variables={[{"id":"pullDistance","type":"number","role":"layout","label":"Pull distance","description":"Raw pull distance before nonlinear rubber-band resistance.","default":120,"min":60,"max":220,"step":5},{"id":"spinnerStyle","type":"enum","role":"content","label":"Spinner style","description":"Refresh indicator geometry and loading motion.","default":"ring","options":[{"value":"arrow","label":"Arrow"},{"value":"dots","label":"Dots"},{"value":"ring","label":"Ring"}]}]}
>
```html pull-to-refresh.html
<!doctype html>
<!--
pull-to-refresh: HyperFrames video primitive (pointers / interaction / demonstrate)
Concept: a mobile list yields under a scripted pull, arms at a visible
threshold, commits into a bounded loading state, then snaps exactly back
to rest. One mechanic, one job: demonstrate a native pull-to-refresh.
Compiled-from evidence: GAP, agent B1 hard miss (video-primitives
candidates card); mobile gesture-physics-recipes.md, section 9 rubber-band
curve and quiet/default/forceful register table. The constants below use
the default register as inspiration, while the self-contained resistance
curve replaces the shared toolkit that is not available in this catalog.
Use when: a mobile product scene needs a recognizable refresh gesture and
loading handoff. Skip it for generic scrolling or a device silhouette.
Variables (declared in data-composition-variables below):
- pullDistance (number, default 120, range 60220): raw pull distance fed
into the nonlinear resistance curve before host-relative translation.
- spinnerStyle ("arrow" | "dots" | "ring", default "ring"): the refresh
indicator. Each option has different geometry and active motion.
Envelope (fixed IN/OUT, elastic loading HOLD only, never gsap.timeScale()):
IN_BASE = 1.80s contact, resistant drag, threshold arm, commit,
handoff, and the first bounded loading cycle
HOLD = elastic = max(0, D - (IN_BASE + OUT_BASE)); additional finite
loading cycles while the content stays at its held offset
OUT_BASE = 0.65s indicator exit and content snap-back
If D < 2.45s, IN and OUT scale down together so IN + OUT == D and HOLD
is zero. The drag remains heavier and slower than the release response.
Sync points (fixed offsets, never inside elastic HOLD):
- impact: 0.82s into unscaled IN, threshold commit and spinner handoff
- settle: 0.65s into unscaled OUT, content reseated exactly at y = 0
Both offsets scale proportionally only when D compresses the envelope.
Sound cues: declarative only. `hf:sfx` events fire for "refresh-commit"
at impact and "refresh-settle" at settle. Scene-level mixing owns audio.
Mount contract: this file is a mountable sub-composition. A host loads it
via data-composition-src, and the runtime clones only <template> contents.
#root fills the host box with position:absolute, inset:0, and
container-type:size. It has no data-width or data-height. All internal
geometry uses cqw/cqh, and the hardcoded composition id is required because
FLATTENED_INNER_ROOT_STRIP_ATTRS removes the mounted root id attribute.
Variables come from window.__hyperframes.getVariables(), which owns merged
declared defaults and per-instance overrides after mounting.
-->
<html
lang="en"
data-composition-variables='[
{ "id": "pullDistance", "type": "number", "role": "layout", "label": "Pull distance", "description": "Raw pull distance before nonlinear rubber-band resistance.", "default": 120, "min": 60, "max": 220, "step": 5 },
{ "id": "spinnerStyle", "type": "enum", "role": "content", "label": "Spinner style", "description": "Refresh indicator geometry and loading motion.", "default": "ring", "options": [{ "value": "arrow", "label": "Arrow" }, { "value": "dots", "label": "Dots" }, { "value": "ring", "label": "Ring" }] }
]'
>
<head>
<meta charset="UTF-8" />
<title>Pull to Refresh</title>
<!-- Metadata only. The mount runtime discards everything outside the
template, while the loader still reads variable declarations from
this html element before cloning the template. -->
</head>
<body>
<template>
<div id="root" data-composition-id="pull-to-refresh" data-duration="4" data-fps="30">
<style>
@property --ptr-progress {
syntax: "<number>";
inherits: true;
initial-value: 0;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
/* INVARIANT: #root is the mount-box owner. The host supplies every
dimension, and all descendants size against this container. */
#root {
position: absolute;
inset: 0;
container-type: size;
isolation: isolate;
overflow: hidden;
color: var(--fg, #f4f7fb);
font-family: var(--font-body, Inter, system-ui, sans-serif);
}
.ptr-clip {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
background: var(--bg, #0b1120);
}
.ptr-indicator {
--ptr-progress: 0;
position: absolute;
z-index: 0;
inset: 0 0 auto;
height: 15cqh;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 1.5cqh;
opacity: 0;
color: var(--brand, #35d6a0);
}
.ptr-indicator-visual {
width: 6.2cqh;
height: 6.2cqh;
display: none;
place-items: center;
}
#root[data-spinner-style="ring"] .ptr-ring,
#root[data-spinner-style="arrow"] .ptr-arrow,
#root[data-spinner-style="dots"] .ptr-dots {
display: grid;
}
/* EDIT ZONE: all three styles read the same --ptr-progress scalar.
Ring maps it to arc fill, arrow maps it to a threshold flip, and
dots map it to a three-step reveal. Active motion stays separate
so the selected style has a distinctive loading silhouette. */
.ptr-ring-core {
width: 100%;
height: 100%;
border-radius: 50%;
background: conic-gradient(
from -90deg,
var(--brand, #35d6a0) 0 calc(var(--ptr-progress) * 1%),
color-mix(in srgb, var(--surface, #1e293b) 86%, transparent)
calc(var(--ptr-progress) * 1%) 100%
);
-webkit-mask: radial-gradient(farthest-side, transparent 59%, var(--fg, #f4f7fb) 61%);
mask: radial-gradient(farthest-side, transparent 59%, var(--fg, #f4f7fb) 61%);
}
.ptr-arrow-progress {
width: 100%;
height: 100%;
display: grid;
place-items: center;
border-radius: 50%;
border: 0.35cqh solid
color-mix(in srgb, var(--brand, #35d6a0) 58%, var(--border, #334155));
background: color-mix(in srgb, var(--surface, #1e293b) 88%, transparent);
transform: rotate(calc(var(--ptr-progress) * 1.8deg));
}
.ptr-arrow-glyph {
position: relative;
width: 1.5cqh;
height: 2.7cqh;
border-radius: 0.3cqh;
background: var(--brand, #35d6a0);
}
.ptr-arrow-glyph::after {
content: "";
position: absolute;
left: 50%;
bottom: -0.8cqh;
width: 2.3cqh;
height: 2.3cqh;
border-right: 0.55cqh solid var(--brand, #35d6a0);
border-bottom: 0.55cqh solid var(--brand, #35d6a0);
transform: translateX(-50%) rotate(45deg);
}
.ptr-dots {
grid-template-columns: repeat(3, 1.7cqh);
gap: 0.8cqh;
align-content: center;
width: auto;
}
.ptr-dot {
width: 1.7cqh;
height: 1.7cqh;
border-radius: 50%;
background: var(--brand, #35d6a0);
box-shadow: 0 0 1.2cqh color-mix(in srgb, var(--brand, #35d6a0) 50%, transparent);
}
.ptr-dot:nth-child(1) {
opacity: clamp(0.2, calc(var(--ptr-progress) / 30), 1);
}
.ptr-dot:nth-child(2) {
opacity: clamp(0.2, calc((var(--ptr-progress) - 30) / 30), 1);
}
.ptr-dot:nth-child(3) {
opacity: clamp(0.2, calc((var(--ptr-progress) - 60) / 30), 1);
}
.ptr-state {
position: relative;
width: 100%;
height: 3.4cqh;
margin-top: 0.9cqh;
color: var(--muted, #94a3b8);
font-family: var(--font-display, Inter, system-ui, sans-serif);
font-size: clamp(1.35cqh, 1.8cqw, 2.05cqh);
font-weight: 700;
letter-spacing: 0.04em;
text-align: center;
text-transform: uppercase;
}
.ptr-state span {
position: absolute;
inset: 0;
opacity: 0;
}
.ptr-content {
position: absolute;
z-index: 1;
inset: 0;
overflow: hidden;
background: var(--bg, #0b1120);
border-radius: inherit;
box-shadow: 0 -1cqh 3cqh color-mix(in srgb, var(--bg, #0b1120) 65%, transparent);
}
.ptr-topbar {
display: flex;
align-items: center;
justify-content: space-between;
height: 10cqh;
padding: 0 6cqw;
border-bottom: 0.12cqh solid var(--border, #334155);
background: color-mix(in srgb, var(--surface, #1e293b) 52%, var(--bg, #0b1120));
}
.ptr-title {
font-family: var(--font-display, Inter, system-ui, sans-serif);
font-size: clamp(2.8cqh, 5.2cqw, 4.3cqh);
font-weight: 760;
letter-spacing: -0.035em;
}
.ptr-updated {
display: flex;
align-items: center;
gap: 1.4cqw;
color: var(--brand, #35d6a0);
font-size: clamp(1.4cqh, 2.2cqw, 2cqh);
font-weight: 700;
opacity: 0;
}
.ptr-updated::before {
content: "";
width: 1.4cqh;
height: 1.4cqh;
border-radius: 50%;
background: var(--brand, #35d6a0);
box-shadow: 0 0 1.2cqh color-mix(in srgb, var(--brand, #35d6a0) 50%, transparent);
}
.ptr-search {
display: flex;
align-items: center;
height: 7cqh;
margin: 3cqh 5cqw 2cqh;
padding: 0 4cqw;
border: 0.12cqh solid var(--border, #334155);
border-radius: 3.5cqh;
background: var(--surface, #1e293b);
color: var(--muted, #94a3b8);
font-size: clamp(1.7cqh, 2.8cqw, 2.5cqh);
}
.ptr-list {
display: grid;
gap: 1.7cqh;
padding: 0 5cqw 5cqh;
}
.ptr-card {
display: grid;
grid-template-columns: 8cqh 1fr auto;
align-items: center;
min-height: 11.5cqh;
gap: 3cqw;
padding: 2cqh 4cqw;
border: 0.12cqh solid var(--border, #334155);
border-radius: 2.4cqh;
background: var(--surface, #1e293b);
box-shadow: 0 1cqh 2.4cqh color-mix(in srgb, var(--bg, #0b1120) 55%, transparent);
}
.ptr-avatar {
display: grid;
place-items: center;
width: 6.3cqh;
height: 6.3cqh;
border-radius: 2cqh;
background: color-mix(in srgb, var(--brand, #35d6a0) 20%, var(--surface, #1e293b));
color: var(--brand, #35d6a0);
font-family: var(--font-display, Inter, system-ui, sans-serif);
font-size: 2.3cqh;
font-weight: 800;
}
.ptr-copy {
min-width: 0;
}
.ptr-card-title {
color: var(--fg, #f4f7fb);
font-family: var(--font-display, Inter, system-ui, sans-serif);
font-size: clamp(1.9cqh, 3.1cqw, 2.7cqh);
font-weight: 720;
}
.ptr-card-subtitle {
margin-top: 0.5cqh;
color: var(--muted, #94a3b8);
font-size: clamp(1.45cqh, 2.3cqw, 2.05cqh);
line-height: 1.25;
}
.ptr-time {
align-self: start;
color: var(--muted, #94a3b8);
font-size: clamp(1.25cqh, 2cqw, 1.8cqh);
font-weight: 650;
}
</style>
<div
id="pull-to-refresh-clip"
class="ptr-clip clip"
data-start="0"
data-duration="4"
data-track-index="0"
>
<div class="ptr-indicator" aria-hidden="true">
<div class="ptr-indicator-visual ptr-ring">
<div class="ptr-ring-core"></div>
</div>
<div class="ptr-indicator-visual ptr-arrow">
<div class="ptr-arrow-progress">
<div class="ptr-arrow-glyph"></div>
</div>
</div>
<div class="ptr-indicator-visual ptr-dots">
<span class="ptr-dot"></span>
<span class="ptr-dot"></span>
<span class="ptr-dot"></span>
</div>
<div class="ptr-state">
<span class="ptr-pull-label">Pull to refresh</span>
<span class="ptr-release-label">Release to refresh</span>
<span class="ptr-loading-label">Refreshing</span>
</div>
</div>
<section class="ptr-content" aria-label="Activity list">
<header class="ptr-topbar">
<div class="ptr-title">Activity</div>
<div class="ptr-updated">Updated now</div>
</header>
<div class="ptr-search">Search activity</div>
<div class="ptr-list">
<article class="ptr-card">
<div class="ptr-avatar">AL</div>
<div class="ptr-copy">
<div class="ptr-card-title">Alex shared a draft</div>
<div class="ptr-card-subtitle">Launch sequence, ready for review</div>
</div>
<div class="ptr-time">Now</div>
</article>
<article class="ptr-card">
<div class="ptr-avatar">MK</div>
<div class="ptr-copy">
<div class="ptr-card-title">Mika left feedback</div>
<div class="ptr-card-subtitle">Three comments on the new flow</div>
</div>
<div class="ptr-time">4m</div>
</article>
<article class="ptr-card">
<div class="ptr-avatar">NO</div>
<div class="ptr-copy">
<div class="ptr-card-title">Noah published an update</div>
<div class="ptr-card-subtitle">Mobile preview is available</div>
</div>
<div class="ptr-time">18m</div>
</article>
<article class="ptr-card">
<div class="ptr-avatar">SR</div>
<div class="ptr-copy">
<div class="ptr-card-title">Sara joined the project</div>
<div class="ptr-card-subtitle">Workspace access granted</div>
</div>
<div class="ptr-time">1h</div>
</article>
</div>
</section>
</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 by contract. Mounted roots lose data-composition-id
// during flattening, so reading the id back from the DOM can
// register the timeline under "null".
var compositionId = "pull-to-refresh";
var clip = root.querySelector(".ptr-clip");
var indicator = root.querySelector(".ptr-indicator");
var content = root.querySelector(".ptr-content");
var pullLabel = root.querySelector(".ptr-pull-label");
var releaseLabel = root.querySelector(".ptr-release-label");
var loadingLabel = root.querySelector(".ptr-loading-label");
var ring = root.querySelector(".ptr-ring-core");
var arrow = root.querySelector(".ptr-arrow-glyph");
var dots = Array.prototype.slice.call(root.querySelectorAll(".ptr-dot"));
var updated = root.querySelector(".ptr-updated");
var vars =
window.__hyperframes && window.__hyperframes.getVariables
? window.__hyperframes.getVariables()
: {};
// INVARIANT: only finite 60220 input reaches the physics owner.
// Zero, NaN, and strings outside the range fall back explicitly.
var rawPull = Number(vars.pullDistance);
var pullDistance = Number.isFinite(rawPull)
? Math.max(60, Math.min(220, rawPull))
: 120;
// INVARIANT: only one of the declared indicator variants reaches
// the renderer. Invalid overrides resolve to the declared default.
var spinnerStyle =
vars.spinnerStyle === "arrow" || vars.spinnerStyle === "dots"
? vars.spinnerStyle
: "ring";
root.setAttribute("data-spinner-style", spinnerStyle);
// Self-contained rubber-band mapping from the physics recipe:
// displayed = x*c / (x*c/d + 1). REFERENCE is a normalized
// preview dimension, then converted to cqh for host-relative
// motion. This function alone owns resistance and displacement.
var RESISTANCE = 0.55;
var REFERENCE = 640;
function rubberBand(distance) {
return (distance * RESISTANCE) / ((distance * RESISTANCE) / REFERENCE + 1);
}
var shownPeak = (rubberBand(pullDistance) / REFERENCE) * 100;
var heldOffset = Math.min(shownPeak, Math.max(5.8, shownPeak * 0.76));
var dragState = { raw: 0 };
// RETIME RANGE: lifecycle ownership lives only in these constants.
// IN and OUT scale together only when the composition duration is short.
var IN_BASE = 1.8;
var OUT_BASE = 0.65;
var CONTACT_BASE = 0.12;
var DRAG_BASE = 0.7;
var ARM_AT_BASE = 0.61;
var IMPACT_AT_BASE = 0.82;
var HANDOFF_BASE = 0.22;
var durationValue = Number(clip.dataset.duration);
var duration = Number.isFinite(durationValue) && durationValue > 0 ? durationValue : 4;
var totalBase = IN_BASE + OUT_BASE;
var scale = duration < totalBase ? duration / totalBase : 1;
var IN = IN_BASE * scale;
var OUT = OUT_BASE * scale;
var CONTACT = CONTACT_BASE * scale;
var DRAG = DRAG_BASE * scale;
var ARM_AT = ARM_AT_BASE * scale;
var IMPACT_AT = IMPACT_AT_BASE * scale;
var HANDOFF = HANDOFF_BASE * scale;
var HOLD = Math.max(0, duration - IN - OUT);
var OUT_START = IN + HOLD;
var ACTIVE_DURATION = Math.max(0.001, OUT_START - IMPACT_AT);
function fireSfx(id, atTime) {
root.dispatchEvent(
new CustomEvent("hf:sfx", {
detail: { id: id, t: atTime },
bubbles: true,
}),
);
}
gsap.set(content, { y: "0cqh" });
gsap.set(indicator, { "--ptr-progress": 0, opacity: 0 });
gsap.set(pullLabel, { opacity: 1 });
gsap.set(releaseLabel, { opacity: 0 });
gsap.set(loadingLabel, { opacity: 0 });
gsap.set(ring, { rotation: 0 });
gsap.set(arrow, { rotation: 0 });
gsap.set(dots, { y: "0cqh", scale: 1 });
gsap.set(updated, { opacity: 0 });
var tl = gsap.timeline({ paused: true });
// IN, contact and nonlinear pull. The distance is already
// resistance-mapped, while power2.out controls drag timing.
tl.fromTo(
indicator,
{ "--ptr-progress": 0, opacity: 0 },
{
"--ptr-progress": 100,
opacity: 1,
duration: DRAG,
ease: "power2.out",
immediateRender: false,
},
CONTACT,
);
tl.fromTo(
dragState,
{ raw: 0 },
{
raw: pullDistance,
duration: DRAG,
ease: "power2.out",
onUpdate: function () {
var displayed = (rubberBand(dragState.raw) / REFERENCE) * 100;
gsap.set(content, { y: displayed + "cqh" });
},
immediateRender: false,
},
CONTACT,
);
// Threshold arm, a fixed point in IN. The indicator geometry is
// full and the label flips before release commits the refresh.
tl.to(pullLabel, { opacity: 0, duration: 0.12 * scale, ease: "power2.in" }, ARM_AT);
tl.to(releaseLabel, { opacity: 1, duration: 0.16 * scale, ease: "power2.out" }, ARM_AT);
tl.addLabel("impact", IMPACT_AT);
tl.fromTo(
content,
{ y: shownPeak + "cqh" },
{
y: heldOffset + "cqh",
duration: HANDOFF,
ease: "power3.out",
immediateRender: false,
},
IMPACT_AT,
);
tl.to(
releaseLabel,
{ opacity: 0, duration: 0.1 * scale, ease: "power2.in" },
IMPACT_AT,
);
tl.to(
loadingLabel,
{ opacity: 1, duration: 0.16 * scale, ease: "power2.out" },
IMPACT_AT,
);
tl.call(
function () {
fireSfx("refresh-commit", IMPACT_AT);
},
[],
IMPACT_AT,
);
// Loading HOLD: every cycle count is finite and determined once.
// Each style owns a distinct active motion, but only the resolved
// style is authored into the timeline.
if (spinnerStyle === "ring") {
var spinCount = Math.max(1, Math.round(ACTIVE_DURATION / 0.58));
tl.fromTo(
ring,
{ rotation: 0 },
{
rotation: 360 * spinCount,
duration: ACTIVE_DURATION,
ease: "linear",
immediateRender: false,
},
IMPACT_AT,
);
} else if (spinnerStyle === "arrow") {
var arrowSpinCount = Math.max(1, Math.round(ACTIVE_DURATION / 0.64));
tl.fromTo(
arrow,
{ rotation: 0 },
{
rotation: 360 * arrowSpinCount,
duration: ACTIVE_DURATION,
ease: "linear",
immediateRender: false,
},
IMPACT_AT,
);
} else {
var PULSE_HALF = 0.22 * scale;
dots.forEach(function (dot, index) {
var dotStart = IMPACT_AT + index * 0.1 * scale;
var available = Math.max(PULSE_HALF, OUT_START - dotStart);
var pulseRepeat = Math.max(1, Math.floor(available / PULSE_HALF) - 1);
tl.fromTo(
dot,
{ y: "0cqh", scale: 1 },
{
y: "-1.15cqh",
scale: 1.28,
duration: PULSE_HALF,
ease: "sine.inOut",
yoyo: true,
repeat: pulseRepeat,
immediateRender: false,
},
dotStart,
);
});
}
// OUT: opacity exits without overshoot. Content alone earns the
// rare tactile back.out snap and lands exactly at zero.
tl.fromTo(
indicator,
{ opacity: 1 },
{
opacity: 0,
duration: Math.min(OUT, 0.2 * scale),
ease: "power2.in",
immediateRender: false,
},
OUT_START,
);
tl.fromTo(
content,
{ y: heldOffset + "cqh" },
{
y: "0cqh",
duration: OUT,
ease: "back.out(1.7)",
immediateRender: false,
},
OUT_START,
);
tl.fromTo(
updated,
{ opacity: 0 },
{
opacity: 1,
duration: Math.min(OUT, 0.28 * scale),
ease: "power2.out",
immediateRender: false,
},
OUT_START + OUT * 0.32,
);
tl.addLabel("settle", OUT_START + OUT);
tl.call(
function () {
fireSfx("refresh-settle", OUT_START + OUT);
},
[],
OUT_START + OUT,
);
tl.seek(0);
window.__timelines = window.__timelines || {};
window.__timelines[compositionId] = tl;
})();
</script>
</div>
</template>
</body>
</html>
```
</VariablesExplorer>
## Install
<InstallCommand command="npx hyperframes add pull-to-refresh" item="pull-to-refresh" />
That writes one file: `compositions/components/pull-to-refresh.html`.
## Paste it into your composition
Open `compositions/components/pull-to-refresh.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 |
| --- | --- | --- | --- |
| `pullDistance` | `120` | 60 to 220, step 5 | Raw pull distance before nonlinear rubber-band resistance. |
| `spinnerStyle` | `ring` | `arrow`, `dots`, `ring` | Refresh indicator geometry and loading motion. |
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="pull-to-refresh"
data-composition-src="compositions/components/pull-to-refresh.html"
data-variable-values='{"pullDistance":120,"spinnerStyle":"ring"}'
></div>
```
## Source
<Accordion title={`pull-to-refresh.html`}>
```html
<!doctype html>
<!--
pull-to-refresh: HyperFrames video primitive (pointers / interaction / demonstrate)
Concept: a mobile list yields under a scripted pull, arms at a visible
threshold, commits into a bounded loading state, then snaps exactly back
to rest. One mechanic, one job: demonstrate a native pull-to-refresh.
Compiled-from evidence: GAP, agent B1 hard miss (video-primitives
candidates card); mobile gesture-physics-recipes.md, section 9 rubber-band
curve and quiet/default/forceful register table. The constants below use
the default register as inspiration, while the self-contained resistance
curve replaces the shared toolkit that is not available in this catalog.
Use when: a mobile product scene needs a recognizable refresh gesture and
loading handoff. Skip it for generic scrolling or a device silhouette.
Variables (declared in data-composition-variables below):
- pullDistance (number, default 120, range 60220): raw pull distance fed
into the nonlinear resistance curve before host-relative translation.
- spinnerStyle ("arrow" | "dots" | "ring", default "ring"): the refresh
indicator. Each option has different geometry and active motion.
Envelope (fixed IN/OUT, elastic loading HOLD only, never gsap.timeScale()):
IN_BASE = 1.80s contact, resistant drag, threshold arm, commit,
handoff, and the first bounded loading cycle
HOLD = elastic = max(0, D - (IN_BASE + OUT_BASE)); additional finite
loading cycles while the content stays at its held offset
OUT_BASE = 0.65s indicator exit and content snap-back
If D < 2.45s, IN and OUT scale down together so IN + OUT == D and HOLD
is zero. The drag remains heavier and slower than the release response.
Sync points (fixed offsets, never inside elastic HOLD):
- impact: 0.82s into unscaled IN, threshold commit and spinner handoff
- settle: 0.65s into unscaled OUT, content reseated exactly at y = 0
Both offsets scale proportionally only when D compresses the envelope.
Sound cues: declarative only. `hf:sfx` events fire for "refresh-commit"
at impact and "refresh-settle" at settle. Scene-level mixing owns audio.
Mount contract: this file is a mountable sub-composition. A host loads it
via data-composition-src, and the runtime clones only <template> contents.
#root fills the host box with position:absolute, inset:0, and
container-type:size. It has no data-width or data-height. All internal
geometry uses cqw/cqh, and the hardcoded composition id is required because
FLATTENED_INNER_ROOT_STRIP_ATTRS removes the mounted root id attribute.
Variables come from window.__hyperframes.getVariables(), which owns merged
declared defaults and per-instance overrides after mounting.
-->
<html
lang="en"
data-composition-variables='[
{ "id": "pullDistance", "type": "number", "role": "layout", "label": "Pull distance", "description": "Raw pull distance before nonlinear rubber-band resistance.", "default": 120, "min": 60, "max": 220, "step": 5 },
{ "id": "spinnerStyle", "type": "enum", "role": "content", "label": "Spinner style", "description": "Refresh indicator geometry and loading motion.", "default": "ring", "options": [{ "value": "arrow", "label": "Arrow" }, { "value": "dots", "label": "Dots" }, { "value": "ring", "label": "Ring" }] }
]'
>
<head>
<meta charset="UTF-8" />
<title>Pull to Refresh</title>
<!-- Metadata only. The mount runtime discards everything outside the
template, while the loader still reads variable declarations from
this html element before cloning the template. -->
</head>
<body>
<template>
<div id="root" data-composition-id="pull-to-refresh" data-duration="4" data-fps="30">
<style>
@property --ptr-progress {
syntax: "<number>";
inherits: true;
initial-value: 0;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
/* INVARIANT: #root is the mount-box owner. The host supplies every
dimension, and all descendants size against this container. */
#root {
position: absolute;
inset: 0;
container-type: size;
isolation: isolate;
overflow: hidden;
color: var(--fg, #f4f7fb);
font-family: var(--font-body, Inter, system-ui, sans-serif);
}
.ptr-clip {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
background: var(--bg, #0b1120);
}
.ptr-indicator {
--ptr-progress: 0;
position: absolute;
z-index: 0;
inset: 0 0 auto;
height: 15cqh;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 1.5cqh;
opacity: 0;
color: var(--brand, #35d6a0);
}
.ptr-indicator-visual {
width: 6.2cqh;
height: 6.2cqh;
display: none;
place-items: center;
}
#root[data-spinner-style="ring"] .ptr-ring,
#root[data-spinner-style="arrow"] .ptr-arrow,
#root[data-spinner-style="dots"] .ptr-dots {
display: grid;
}
/* EDIT ZONE: all three styles read the same --ptr-progress scalar.
Ring maps it to arc fill, arrow maps it to a threshold flip, and
dots map it to a three-step reveal. Active motion stays separate
so the selected style has a distinctive loading silhouette. */
.ptr-ring-core {
width: 100%;
height: 100%;
border-radius: 50%;
background: conic-gradient(
from -90deg,
var(--brand, #35d6a0) 0 calc(var(--ptr-progress) * 1%),
color-mix(in srgb, var(--surface, #1e293b) 86%, transparent)
calc(var(--ptr-progress) * 1%) 100%
);
-webkit-mask: radial-gradient(farthest-side, transparent 59%, var(--fg, #f4f7fb) 61%);
mask: radial-gradient(farthest-side, transparent 59%, var(--fg, #f4f7fb) 61%);
}
.ptr-arrow-progress {
width: 100%;
height: 100%;
display: grid;
place-items: center;
border-radius: 50%;
border: 0.35cqh solid
color-mix(in srgb, var(--brand, #35d6a0) 58%, var(--border, #334155));
background: color-mix(in srgb, var(--surface, #1e293b) 88%, transparent);
transform: rotate(calc(var(--ptr-progress) * 1.8deg));
}
.ptr-arrow-glyph {
position: relative;
width: 1.5cqh;
height: 2.7cqh;
border-radius: 0.3cqh;
background: var(--brand, #35d6a0);
}
.ptr-arrow-glyph::after {
content: "";
position: absolute;
left: 50%;
bottom: -0.8cqh;
width: 2.3cqh;
height: 2.3cqh;
border-right: 0.55cqh solid var(--brand, #35d6a0);
border-bottom: 0.55cqh solid var(--brand, #35d6a0);
transform: translateX(-50%) rotate(45deg);
}
.ptr-dots {
grid-template-columns: repeat(3, 1.7cqh);
gap: 0.8cqh;
align-content: center;
width: auto;
}
.ptr-dot {
width: 1.7cqh;
height: 1.7cqh;
border-radius: 50%;
background: var(--brand, #35d6a0);
box-shadow: 0 0 1.2cqh color-mix(in srgb, var(--brand, #35d6a0) 50%, transparent);
}
.ptr-dot:nth-child(1) {
opacity: clamp(0.2, calc(var(--ptr-progress) / 30), 1);
}
.ptr-dot:nth-child(2) {
opacity: clamp(0.2, calc((var(--ptr-progress) - 30) / 30), 1);
}
.ptr-dot:nth-child(3) {
opacity: clamp(0.2, calc((var(--ptr-progress) - 60) / 30), 1);
}
.ptr-state {
position: relative;
width: 100%;
height: 3.4cqh;
margin-top: 0.9cqh;
color: var(--muted, #94a3b8);
font-family: var(--font-display, Inter, system-ui, sans-serif);
font-size: clamp(1.35cqh, 1.8cqw, 2.05cqh);
font-weight: 700;
letter-spacing: 0.04em;
text-align: center;
text-transform: uppercase;
}
.ptr-state span {
position: absolute;
inset: 0;
opacity: 0;
}
.ptr-content {
position: absolute;
z-index: 1;
inset: 0;
overflow: hidden;
background: var(--bg, #0b1120);
border-radius: inherit;
box-shadow: 0 -1cqh 3cqh color-mix(in srgb, var(--bg, #0b1120) 65%, transparent);
}
.ptr-topbar {
display: flex;
align-items: center;
justify-content: space-between;
height: 10cqh;
padding: 0 6cqw;
border-bottom: 0.12cqh solid var(--border, #334155);
background: color-mix(in srgb, var(--surface, #1e293b) 52%, var(--bg, #0b1120));
}
.ptr-title {
font-family: var(--font-display, Inter, system-ui, sans-serif);
font-size: clamp(2.8cqh, 5.2cqw, 4.3cqh);
font-weight: 760;
letter-spacing: -0.035em;
}
.ptr-updated {
display: flex;
align-items: center;
gap: 1.4cqw;
color: var(--brand, #35d6a0);
font-size: clamp(1.4cqh, 2.2cqw, 2cqh);
font-weight: 700;
opacity: 0;
}
.ptr-updated::before {
content: "";
width: 1.4cqh;
height: 1.4cqh;
border-radius: 50%;
background: var(--brand, #35d6a0);
box-shadow: 0 0 1.2cqh color-mix(in srgb, var(--brand, #35d6a0) 50%, transparent);
}
.ptr-search {
display: flex;
align-items: center;
height: 7cqh;
margin: 3cqh 5cqw 2cqh;
padding: 0 4cqw;
border: 0.12cqh solid var(--border, #334155);
border-radius: 3.5cqh;
background: var(--surface, #1e293b);
color: var(--muted, #94a3b8);
font-size: clamp(1.7cqh, 2.8cqw, 2.5cqh);
}
.ptr-list {
display: grid;
gap: 1.7cqh;
padding: 0 5cqw 5cqh;
}
.ptr-card {
display: grid;
grid-template-columns: 8cqh 1fr auto;
align-items: center;
min-height: 11.5cqh;
gap: 3cqw;
padding: 2cqh 4cqw;
border: 0.12cqh solid var(--border, #334155);
border-radius: 2.4cqh;
background: var(--surface, #1e293b);
box-shadow: 0 1cqh 2.4cqh color-mix(in srgb, var(--bg, #0b1120) 55%, transparent);
}
.ptr-avatar {
display: grid;
place-items: center;
width: 6.3cqh;
height: 6.3cqh;
border-radius: 2cqh;
background: color-mix(in srgb, var(--brand, #35d6a0) 20%, var(--surface, #1e293b));
color: var(--brand, #35d6a0);
font-family: var(--font-display, Inter, system-ui, sans-serif);
font-size: 2.3cqh;
font-weight: 800;
}
.ptr-copy {
min-width: 0;
}
.ptr-card-title {
color: var(--fg, #f4f7fb);
font-family: var(--font-display, Inter, system-ui, sans-serif);
font-size: clamp(1.9cqh, 3.1cqw, 2.7cqh);
font-weight: 720;
}
.ptr-card-subtitle {
margin-top: 0.5cqh;
color: var(--muted, #94a3b8);
font-size: clamp(1.45cqh, 2.3cqw, 2.05cqh);
line-height: 1.25;
}
.ptr-time {
align-self: start;
color: var(--muted, #94a3b8);
font-size: clamp(1.25cqh, 2cqw, 1.8cqh);
font-weight: 650;
}
</style>
<div
id="pull-to-refresh-clip"
class="ptr-clip clip"
data-start="0"
data-duration="4"
data-track-index="0"
>
<div class="ptr-indicator" aria-hidden="true">
<div class="ptr-indicator-visual ptr-ring">
<div class="ptr-ring-core"></div>
</div>
<div class="ptr-indicator-visual ptr-arrow">
<div class="ptr-arrow-progress">
<div class="ptr-arrow-glyph"></div>
</div>
</div>
<div class="ptr-indicator-visual ptr-dots">
<span class="ptr-dot"></span>
<span class="ptr-dot"></span>
<span class="ptr-dot"></span>
</div>
<div class="ptr-state">
<span class="ptr-pull-label">Pull to refresh</span>
<span class="ptr-release-label">Release to refresh</span>
<span class="ptr-loading-label">Refreshing</span>
</div>
</div>
<section class="ptr-content" aria-label="Activity list">
<header class="ptr-topbar">
<div class="ptr-title">Activity</div>
<div class="ptr-updated">Updated now</div>
</header>
<div class="ptr-search">Search activity</div>
<div class="ptr-list">
<article class="ptr-card">
<div class="ptr-avatar">AL</div>
<div class="ptr-copy">
<div class="ptr-card-title">Alex shared a draft</div>
<div class="ptr-card-subtitle">Launch sequence, ready for review</div>
</div>
<div class="ptr-time">Now</div>
</article>
<article class="ptr-card">
<div class="ptr-avatar">MK</div>
<div class="ptr-copy">
<div class="ptr-card-title">Mika left feedback</div>
<div class="ptr-card-subtitle">Three comments on the new flow</div>
</div>
<div class="ptr-time">4m</div>
</article>
<article class="ptr-card">
<div class="ptr-avatar">NO</div>
<div class="ptr-copy">
<div class="ptr-card-title">Noah published an update</div>
<div class="ptr-card-subtitle">Mobile preview is available</div>
</div>
<div class="ptr-time">18m</div>
</article>
<article class="ptr-card">
<div class="ptr-avatar">SR</div>
<div class="ptr-copy">
<div class="ptr-card-title">Sara joined the project</div>
<div class="ptr-card-subtitle">Workspace access granted</div>
</div>
<div class="ptr-time">1h</div>
</article>
</div>
</section>
</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 by contract. Mounted roots lose data-composition-id
// during flattening, so reading the id back from the DOM can
// register the timeline under "null".
var compositionId = "pull-to-refresh";
var clip = root.querySelector(".ptr-clip");
var indicator = root.querySelector(".ptr-indicator");
var content = root.querySelector(".ptr-content");
var pullLabel = root.querySelector(".ptr-pull-label");
var releaseLabel = root.querySelector(".ptr-release-label");
var loadingLabel = root.querySelector(".ptr-loading-label");
var ring = root.querySelector(".ptr-ring-core");
var arrow = root.querySelector(".ptr-arrow-glyph");
var dots = Array.prototype.slice.call(root.querySelectorAll(".ptr-dot"));
var updated = root.querySelector(".ptr-updated");
var vars =
window.__hyperframes && window.__hyperframes.getVariables
? window.__hyperframes.getVariables()
: {};
// INVARIANT: only finite 60220 input reaches the physics owner.
// Zero, NaN, and strings outside the range fall back explicitly.
var rawPull = Number(vars.pullDistance);
var pullDistance = Number.isFinite(rawPull)
? Math.max(60, Math.min(220, rawPull))
: 120;
// INVARIANT: only one of the declared indicator variants reaches
// the renderer. Invalid overrides resolve to the declared default.
var spinnerStyle =
vars.spinnerStyle === "arrow" || vars.spinnerStyle === "dots"
? vars.spinnerStyle
: "ring";
root.setAttribute("data-spinner-style", spinnerStyle);
// Self-contained rubber-band mapping from the physics recipe:
// displayed = x*c / (x*c/d + 1). REFERENCE is a normalized
// preview dimension, then converted to cqh for host-relative
// motion. This function alone owns resistance and displacement.
var RESISTANCE = 0.55;
var REFERENCE = 640;
function rubberBand(distance) {
return (distance * RESISTANCE) / ((distance * RESISTANCE) / REFERENCE + 1);
}
var shownPeak = (rubberBand(pullDistance) / REFERENCE) * 100;
var heldOffset = Math.min(shownPeak, Math.max(5.8, shownPeak * 0.76));
var dragState = { raw: 0 };
// RETIME RANGE: lifecycle ownership lives only in these constants.
// IN and OUT scale together only when the composition duration is short.
var IN_BASE = 1.8;
var OUT_BASE = 0.65;
var CONTACT_BASE = 0.12;
var DRAG_BASE = 0.7;
var ARM_AT_BASE = 0.61;
var IMPACT_AT_BASE = 0.82;
var HANDOFF_BASE = 0.22;
var durationValue = Number(clip.dataset.duration);
var duration = Number.isFinite(durationValue) && durationValue > 0 ? durationValue : 4;
var totalBase = IN_BASE + OUT_BASE;
var scale = duration < totalBase ? duration / totalBase : 1;
var IN = IN_BASE * scale;
var OUT = OUT_BASE * scale;
var CONTACT = CONTACT_BASE * scale;
var DRAG = DRAG_BASE * scale;
var ARM_AT = ARM_AT_BASE * scale;
var IMPACT_AT = IMPACT_AT_BASE * scale;
var HANDOFF = HANDOFF_BASE * scale;
var HOLD = Math.max(0, duration - IN - OUT);
var OUT_START = IN + HOLD;
var ACTIVE_DURATION = Math.max(0.001, OUT_START - IMPACT_AT);
function fireSfx(id, atTime) {
root.dispatchEvent(
new CustomEvent("hf:sfx", {
detail: { id: id, t: atTime },
bubbles: true,
}),
);
}
gsap.set(content, { y: "0cqh" });
gsap.set(indicator, { "--ptr-progress": 0, opacity: 0 });
gsap.set(pullLabel, { opacity: 1 });
gsap.set(releaseLabel, { opacity: 0 });
gsap.set(loadingLabel, { opacity: 0 });
gsap.set(ring, { rotation: 0 });
gsap.set(arrow, { rotation: 0 });
gsap.set(dots, { y: "0cqh", scale: 1 });
gsap.set(updated, { opacity: 0 });
var tl = gsap.timeline({ paused: true });
// IN, contact and nonlinear pull. The distance is already
// resistance-mapped, while power2.out controls drag timing.
tl.fromTo(
indicator,
{ "--ptr-progress": 0, opacity: 0 },
{
"--ptr-progress": 100,
opacity: 1,
duration: DRAG,
ease: "power2.out",
immediateRender: false,
},
CONTACT,
);
tl.fromTo(
dragState,
{ raw: 0 },
{
raw: pullDistance,
duration: DRAG,
ease: "power2.out",
onUpdate: function () {
var displayed = (rubberBand(dragState.raw) / REFERENCE) * 100;
gsap.set(content, { y: displayed + "cqh" });
},
immediateRender: false,
},
CONTACT,
);
// Threshold arm, a fixed point in IN. The indicator geometry is
// full and the label flips before release commits the refresh.
tl.to(pullLabel, { opacity: 0, duration: 0.12 * scale, ease: "power2.in" }, ARM_AT);
tl.to(releaseLabel, { opacity: 1, duration: 0.16 * scale, ease: "power2.out" }, ARM_AT);
tl.addLabel("impact", IMPACT_AT);
tl.fromTo(
content,
{ y: shownPeak + "cqh" },
{
y: heldOffset + "cqh",
duration: HANDOFF,
ease: "power3.out",
immediateRender: false,
},
IMPACT_AT,
);
tl.to(
releaseLabel,
{ opacity: 0, duration: 0.1 * scale, ease: "power2.in" },
IMPACT_AT,
);
tl.to(
loadingLabel,
{ opacity: 1, duration: 0.16 * scale, ease: "power2.out" },
IMPACT_AT,
);
tl.call(
function () {
fireSfx("refresh-commit", IMPACT_AT);
},
[],
IMPACT_AT,
);
// Loading HOLD: every cycle count is finite and determined once.
// Each style owns a distinct active motion, but only the resolved
// style is authored into the timeline.
if (spinnerStyle === "ring") {
var spinCount = Math.max(1, Math.round(ACTIVE_DURATION / 0.58));
tl.fromTo(
ring,
{ rotation: 0 },
{
rotation: 360 * spinCount,
duration: ACTIVE_DURATION,
ease: "linear",
immediateRender: false,
},
IMPACT_AT,
);
} else if (spinnerStyle === "arrow") {
var arrowSpinCount = Math.max(1, Math.round(ACTIVE_DURATION / 0.64));
tl.fromTo(
arrow,
{ rotation: 0 },
{
rotation: 360 * arrowSpinCount,
duration: ACTIVE_DURATION,
ease: "linear",
immediateRender: false,
},
IMPACT_AT,
);
} else {
var PULSE_HALF = 0.22 * scale;
dots.forEach(function (dot, index) {
var dotStart = IMPACT_AT + index * 0.1 * scale;
var available = Math.max(PULSE_HALF, OUT_START - dotStart);
var pulseRepeat = Math.max(1, Math.floor(available / PULSE_HALF) - 1);
tl.fromTo(
dot,
{ y: "0cqh", scale: 1 },
{
y: "-1.15cqh",
scale: 1.28,
duration: PULSE_HALF,
ease: "sine.inOut",
yoyo: true,
repeat: pulseRepeat,
immediateRender: false,
},
dotStart,
);
});
}
// OUT: opacity exits without overshoot. Content alone earns the
// rare tactile back.out snap and lands exactly at zero.
tl.fromTo(
indicator,
{ opacity: 1 },
{
opacity: 0,
duration: Math.min(OUT, 0.2 * scale),
ease: "power2.in",
immediateRender: false,
},
OUT_START,
);
tl.fromTo(
content,
{ y: heldOffset + "cqh" },
{
y: "0cqh",
duration: OUT,
ease: "back.out(1.7)",
immediateRender: false,
},
OUT_START,
);
tl.fromTo(
updated,
{ opacity: 0 },
{
opacity: 1,
duration: Math.min(OUT, 0.28 * scale),
ease: "power2.out",
immediateRender: false,
},
OUT_START + OUT * 0.32,
);
tl.addLabel("settle", OUT_START + OUT);
tl.call(
function () {
fireSfx("refresh-settle", OUT_START + OUT);
},
[],
OUT_START + OUT,
);
tl.seek(0);
window.__timelines = window.__timelines || {};
window.__timelines[compositionId] = tl;
})();
</script>
</div>
</template>
</body>
</html>
```
</Accordion>
{/* hf:generated-footer */}
Tagged `pointer` `pointers` `mobile` `gesture` `interaction` `refresh` `demonstrate`.
## Related topics
- [Browse the complete Catalog](/catalog)
- [Add assets and Catalog items in Studio](/studio/assets-and-blocks)
- [Build a richer composition](/go-further)