Dynamic Island metaball capsule

I wanted to know if one WebGL 2 canvas can morph a liquid obsidian Dynamic Island between a compact pill, split twin bubbles and expanded widgets with crisp live HTML controls inside. Switch states below or tap the capsule, drag the twin orb to stretch and pinch off the black neck, edit the track title or start the timer.

ElementGL ยท 48 kHz
1:18 3:40
Maya Chen Incoming audio call
Timer 00:45.0
State: split Neck: bridged starting
Show the code smin SDF shader, spring physics, ElementGL paint and hit-test calibration
  1. Five drawable panels in one canvas. The compact pill, split pill, draggable orb, media player and timer/call widget sit inside one <canvas content="drawable" layoutsubtree>, with inert hiding whichever panels are off-stage.
  2. Smooth-union SDF and crisp post-pass DOM compositing. Evaluates cubic smin(d1, d2, k) for the obsidian silhouette and specular rim, then samples each live panel at 1:1 CSS pixels inside the SDF mask so text stays sharp.
  3. Damped springs and drag-to-pinch. Integrates capsule size and detached orb position with critically damped springs, or snaps immediately when prefers-reduced-motion: reduce is active.
  4. Single-context paint and geometry sync. Uploads only dirty panels through ElementGL.upload() (texElementSubImage2D()) and updates updateElementGeometry() scaled by geometryUnit() with dataset.hitTick cache clearing.
  5. Five-argument 2D and plain-HTML fallbacks. Draws the island with explicit 5-argument drawElementImage() without WebGL 2, and moves panels to plain HTML on context loss.

How it works

Every island widget lives as a drawable child inside one <canvas content="drawable" layoutsubtree> backed by one WebGL 2 context from ElementGL (/lib/element-gl.js). When a state switches, I toggle inert on the inactive panels, move focus cleanly if needed, and push their hit boxes off-stage while uploading only the panels whose DOM actually changed through gl.texElementSubImage2D().

Standard CSS gooey effects blur the DOM layer before thresholding alpha, which softens letter edges and slider hairlines. Here the fragment shader runs two stages in one pass. First it evaluates signed distances d1 for the rounded main capsule and d2 for the satellite orb, combines them with a C2-continuous cubic smooth minimum smin(d1, d2, k), shades the glossy obsidian fill and directional OLED specular rim, and optionally draws the SDF field and neck bridge strength. Only after that mask is fixed does it sample the uploaded DOM textures at 1:1 CSS layout coordinates inside the capsule mask, so text and buttons stay crisp even while the neck stretches.

Dragging the satellite orb updates a spring target clamped inside the dark mobile frame and releases back to the twin resting gap of 8 px. Because WebGL texture draws don't move Chromium's hit boxes, syncGeometry() calibrates the canvas unit once per resize with geometryUnit() from /lib/surface.js, calls canvas.updateElementGeometry() for each active panel and toggles dataset.hitTick to clear the hit-test cache. An IntersectionObserver pauses the animation loop when the stage leaves the screen, and prefers-reduced-motion: reduce removes spring oscillation so state changes jump cleanly.

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