Multi-detent refractive bottom sheet

I wanted to know if one WebGL canvas can coordinate a three-detent spring bottom sheet with single-gesture scroll handoff at scrollTop === 0, while scaling, dimming and edge-refracting a live map underneath rounded corners. Drag the handle or pull down past the top of the place list, flick between 18%, 52% and 90%, or tap controls on both layers.

Waterfront · 12 places
Gesture owner: Idle · 52% · r 24 px

Starting...

Show the code backdrop depth shader, velocity spring, single-gesture scroll handoff and geometry sync
  1. Two layered drawable views in one canvas. The live street map (#backdrop-dom) and the scrollable sheet (#sheet-dom) sit inside one <canvas content="drawable" layoutsubtree>.
  2. Progressive blur, dimming and curved edge refraction. Pass 0 scales and dims the map as the sheet rises; Pass 1 refracts uBgTex around the top rounded corners (morphing from 24 px down to 8 px) and frosts the translucent header behind real inputs and chips.
  3. Velocity-aware multi-detent spring solver. Projects release velocity onto the 18%, 52% and 90% detents and integrates a sub-stepped damped spring, or snaps directly under prefers-reduced-motion: reduce.
  4. Single-gesture nested-scroll handoff. Consumes downward drag inside #sheet-scroll until scrollTop === 0, then feeds remaining movement straight into the sheet position without lifting the pointer.
  5. Geometry calibration and fallbacks. Multiplies both layer transforms by geometryUnit() before calling updateElementGeometry(), toggles dataset.hitTick when bounds move, and drops to five-argument drawElementImage() or plain HTML if needed.

How it works

Standard CSS backdrop-filter: blur() can frost pixels behind a panel, yet native browser touch scrolling still breaks single-gesture nested handoff: once touch-action: pan-y starts a compositor scroll on an inner list, Chrome sends pointercancel and locks the rest of that finger gesture inside the scroller even after scrollTop reaches zero. Putting both layers inside one ElementGL WebGL 2 canvas lets one pointer controller manage both the sheet height and #sheet-scroll.scrollTop while the fragment shader handles glass blur and curved edge refraction.

Inside <canvas content="drawable" layoutsubtree>, #backdrop-dom renders real HTML buttons (Recentre, Traffic and five clickable map pins) over a CSS street grid, harbour water, parks, traffic lanes and a route path. On each paint event, ElementGL.upload() copies changed elements with gl.texElementSubImage2D(). Pass 0 scales the map down slightly toward 94.5% as the sheet climbs from Peek (18%) to Full (90%), dims it proportionally and casts an upward drop shadow along the sheet's rounded rim.

Pass 1 draws #sheet-dom at sheetTop and binds the backdrop texture to TEXTURE1. A top-only rounded-rectangle signed distance field morphs the corner radius from 24 px down to 8 px near full height, bends UV coordinates with Snell's law and mild RGB dispersion along the top bevel, applies a 9-tap progressive frost blur across the transparent .sheet-header, and composites the crisp premultiplied DOM pixels on top.

For hit testing, syncGeometry() calibrates both transforms with geometryUnit() from /lib/surface.js and updates canvas.updateElementGeometry() only when the coordinates move, toggling dataset.hitTick to clear Chromium's hit-test cache without triggering an idle paint loop. When WebGL 2 isn't available, the stage falls back to five-argument drawElementImage() in 2D, or moves both subtrees into plain HTML on context loss.

Live checks

These checks run on isolated fixtures on the test stage and leave the demo above untouched. Tap the button below to run them in this browser.

Findings