Elastic peel-away swipe list
I wanted to see if a scrollable inbox inside one ElementGL WebGL 2 canvas could arbitrate vertical touch pans against horizontal row swipes, while curling or rubber-banding the live HTML rows over Archive and Delete strips and spring-collapsing the list. Scroll the feed up and down, tap any Star or checkbox, or swipe a row left or right.
All six messages archived or deleted.
Show the code touch arbitration, 28x10 peel and taffy shaders, springs, geometry sync
- Six live inbox rows inside one drawable canvas. Each row is a direct
drawablechild inside a sticky WebGL canvas over anoverflow-y: autoscroll track. - Angle-locked touch arbitration. An 8 px deadzone separates taps on Star or checkbox controls from directional locks:
|dx| > 8and|dx| > |dy| * 1.4locks horizontal peel, while|dy| > 8yields to vertical scroll. - 28 by 10 Sticker Peel and Elastic Taffy shaders. Sticker Peel curls the row round a rolling cylinder and shades
gl_FrontFacingvs the matte underside with a lit specular crease over procedural SDF Archive and Delete strips; Elastic Taffy stretches the leading edge ahead of the trailing anchor with Poisson necking. - 240 Hz sub-stepped spring collapse. Releasing past 42% flings the row away and spring-collapses lower rows upward, or settles immediately under
prefers-reduced-motion: reduce. - Hit-box tracking with
updateElementGeometry(). Each visible row's matrix scales bygeometryUnit()and togglesdataset.hitTickonly when its quantized slot orinertflag changes. - Single
ElementGLpass and 2D 5-argument fallback. Uploads dirty rows viatexElementSubImage2D()and drops to 5-argumentdrawElementImage()or plain HTML if WebGL is missing or lost.
How it works
Six live HTML inbox rows sit directly inside one <canvas content="drawable" layoutsubtree> backed by a single ElementGL WebGL 2 context from /lib/element-gl.js. Rather than growing the canvas to the full list height (which risks crossing 4 megapixels on a phone), the canvas uses position: sticky; top: 0 at 388 CSS pixels tall (368 px below 520 px wide) inside an overflow-y: auto feed track. That keeps the GPU backing store around 1 megapixel at 412 px wide and 2.625 DPR while native wheel, scrollbar and touch-action: pan-y momentum scroll keep working.
When your finger or pointer moves past an 8 px deadzone, decideLock() compares horizontal and vertical travel. If |dx| > 8 and |dx| > |dy| * 1.4, horizontal peel locks, setPointerCapture() holds the pointer, and a non-passive touchmove guard prevents vertical drift from stealing the swipe. Otherwise, |dy| > 8 yields to native vertical scrolling without bending the row. Short taps inside the 8 px deadzone pass straight through to the row's Star button or checkbox.
In Sticker Peel mode, a 28 by 10 triangle mesh wraps the peeled edge round a 3D cylinder whose axis tilts slightly with vertical grab position. Reversed column draw order (Painter's sorting) renders the flat adhesive face first and the lifted curl on top, using gl_FrontFacing to paint the live HTML card on the front and a matte paper underside with a lit specular crease on the back. In Elastic Taffy mode, the leading edge pulls ahead of a lagging trailing anchor while the row waist narrows via Poisson necking until it pops at the 42% commit threshold.
Releasing past 42% (or pressing "Swipe row #2 demo") completes the swipe, spring-collapses the row slot upward via 240 Hz symplectic springs, detaches the committed row, and calls stage.forget(el) to delete its GPU texture without leaks. "Undo last" re-inserts the exact DOM node (preserving its starred or checked state) so the next paint event re-uploads it via texElementSubImage2D(). If WebGL 2 isn't available, the page falls back to 5-argument drawElementImage(), and on context loss or missing HTML-in-canvas it moves all live rows into plain HTML.
Live checks
Each check builds an isolated fixture on testStage() and waits for a tap so opening the page doesn't open extra WebGL contexts or steal focus.
| Status | Check | Detail |
|---|
Findings
- Static checks run on 2026-11-27 (
node --check public/swipe-peel/peel.js,node tools/gfx/check.mjs, andnode tools/writing/check.mjs --strict /swipe-peel/). Live browser runs in headless Chromium 157 and Chrome 159 on Android are not verified yet. - Using a sticky viewport-sized
ElementGLcanvas inside an outeroverflow-y: autoscroll track keeps the GPU canvas near 1 megapixel at 412 px and 2.625 DPR regardless of list length, while keeping directdrawablechildren unclipped. - Reversing column triangle index order for right-side peels avoids depth-buffer alpha artefacts along rounded row corners while still keeping the curled underside above the flat adhesive section.
- Calling
stage.forget(rowEl)as soon as a row finishes collapsing deletes its WebGL texture immediately, while keeping the detached DOM element in the undo stack preserves checkbox and Star state for instant re-upload on Undo.