Pull-to-refresh and stretch overscroll

I wanted to see if one WebGL 2 canvas could hold a live scrolling mobile feed, stretch it from either edge like Android 12+, and pull a liquid metaball spinner out of its sticky header. Scroll inside the phone frame, tug past the top or bottom boundary, or press the trigger buttons to compare non-uniform UV strain against a uniform scale.

Field Feed 8 items
At top
Shaders01 · Top anchor

Non-uniform edge elongation

Pulling past scrollTop 0 stretches rows near the top edge up to 2.6x while lower cards compress slightly so the viewport stays pinned.

Shaders02 · SDF bridge

Analytic 2D metaball droplet

The spinner bulb necks out of the sticky header using 1/d1 + 1/d2 > 1.0 and snaps free when pullPx crosses 78 px.

Scroll03 · Containment

Native inner scroll with overscroll-behavior-y

The scrollable container carries drawable directly, so touch pans and mouse wheel scroll inside without chaining out to the page.

Scroll04 · Hit boxes

Button clicks stay aligned at any scrollTop

After uploading with texElementSubImage2D(), updateElementGeometry() scales the transform by geometryUnit() and flips dataset.hitTick.

Shaders05 · Comparison

Why CSS scaleY() feels flatter

Switch to Uniform CSS-like scale above to see constant strain across every row and clipping at the far edge instead of local compression.

Scroll06 · Rubber band

Logarithmic drag resistance

Finger and wheel deltas past the scroll boundary pass through k * log1p(d / k) so the pull tightens progressively towards 120 px.

Shaders07 · Bottom pull

Mirrored bottom overscroll curve

Scrolling past the end and dragging up reverses the exponential decay to stretch the bottom rows most while pinning the top edge.

Scroll08 · Bottom anchor

Fallbacks without WebGL 2

If texElementSubImage2D() isn't present, the feed draws in 5-argument 2D strips via drawElementImage(), or drops to plain HTML on context loss.

Starting...

Show the code drawable scroller markup, non-uniform stretch shader, metaball SDF and geometry sync
  1. Live scrollable feed inside one canvas. Making #feed-scroll itself the single drawable element keeps sticky headers, inputs and scrolled cards in one paint record.
  2. Non-uniform stretch fragment shader. Deforms texture Y near the pulled edge with y - A * y * (1 - y) * exp(-k * y) and mirrors for bottom pulls.
  3. Analytic 2D metaball pull-to-refresh droplet. Sums r1/d1 + r2/d2 from the header bottom edge and droplet sphere, snapping free past 78 px.
  4. Logarithmic rubber-band and damped spring physics. Shared between the main demo and the isolated live checks.
  5. Hit-box calibration with updateElementGeometry(). Multiplies the transform by geometryUnit() and flips dataset.hitTick.
  6. Five-argument 2D strip fallback. Copies a plain snapshot and draws slices with 5-argument drawElementImage() when WebGL 2 isn't available.

How it works

The phone frame holds one <canvas content="drawable" layoutsubtree> managed by a single ElementGL WebGL 2 context from /lib/element-gl.js. Its only drawable child is #feed-scroll, which sets overflow-y: auto, overscroll-behavior-y: contain and touch-action: pan-y. Keeping drawable on the scroll container itself (and not on individual cards inside it) lets Chromium paint the sticky header, filter chips, text input and scrolled cards in one texture via gl.texElementSubImage2D() while native wheel and touch scrolling work directly on the box.

When you drag past scrollTop === 0 or past the bottom limit, excess delta passes through a logarithmic rubber-band curve 56 * log1p(d / 56) up to 120 px. In Android stretch mode, the fragment shader maps screen Y to texture Y using y - A * y * (1 - y) * exp(-3.2 * y). Because its slope is below 1 near y = 0 and slightly above 1 further down, rows near the pulled edge elongate up to 2.6x while distant rows compress gently and both boundaries stay fixed in the viewport. Uniform scale mode replaces that curve with linear scaleY() so you can compare the clipping and constant strain.

During a top pull above scrollTop === 0, the shader evaluates a two-source 2D metaball scalar field r1 / d1 + r2 / d2 anchored at the stretched bottom edge of the sticky header. Pulling towards 78 px thins the liquid neck until the critical distance breaks it cleanly into a floating sphere with a spinning loader arc, prepends a new timestamped row to the live DOM feed and springs pullPx back to 0. When the spring settles, or when the frame scrolls off screen, the animation loop stops completely.

WebGL uploads don't move hit regions by themselves, so syncGeometry() scales the feed's DOMMatrix by geometryUnit() from /lib/surface.js, passes it to canvas.updateElementGeometry() and toggles dataset.hitTick to clear Chromium's hit-test cache. If WebGL 2 isn't available, the canvas falls back to 5-argument drawElementImage() strips in 2D, and if the context is lost it moves #feed-scroll into plain HTML so controls stay usable.

Live checks

Each check builds an isolated fixture on testStage() without scrolling or focusing the demo above. Press Run to execute them in this browser.

Findings