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.
Starting...
Show the code backdrop depth shader, velocity spring, single-gesture scroll handoff and geometry sync
- Two layered
drawableviews in one canvas. The live street map (#backdrop-dom) and the scrollable sheet (#sheet-dom) sit inside one<canvas content="drawable" layoutsubtree>. - Progressive blur, dimming and curved edge refraction. Pass 0 scales and dims the map as the sheet rises; Pass 1 refracts
uBgTexaround the top rounded corners (morphing from24 pxdown to8 px) and frosts the translucent header behind real inputs and chips. - 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. - Single-gesture nested-scroll handoff. Consumes downward drag inside
#sheet-scrolluntilscrollTop === 0, then feeds remaining movement straight into the sheet position without lifting the pointer. - Geometry calibration and fallbacks. Multiplies both layer transforms by
geometryUnit()before callingupdateElementGeometry(), togglesdataset.hitTickwhen bounds move, and drops to five-argumentdrawElementImage()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
- Not verified in a live browser yet: syntax, graphics rules and prose checks pass, while headless Chromium 157 and Chrome 159 on Android runs are still pending.
- Driving
#sheet-scroll.scrollTopandsheetFracfrom onepointermovestate machine withtouch-action: noneavoids Chrome's mid-gesturepointercancel, so dragging down throughscrollTop === 0continues pulling the sheet down to Half or Peek without lifting your finger, while mouse wheel and keyboard scrolling still scroll#sheet-scrollnatively. - Keeping
#sheet-domat a fixed 94% height and translating it viaupdateElementGeometry()avoids CSS layout reflow during spring animations and keeps the inner list'sscrollTopintact when you pull the sheet down and push it back up. - Pinning the map's
RecentreandTrafficbuttons inside the top 40 px strip leaves them uncovered and clickable even at Full (90%) detent after the 94.5% backdrop scale.