Hold-to-delete ember burn card
I wanted to rebuild Keshav Bagaade's Hold to Delete with HTML-in-canvas, so that the burning page is live DOM rather than a baked bitmap. Edit the key title or notes, then press and hold Hold to delete: an FBM ember front spreads from the button's exact CSS bounding box, cools back intact if you let go early, or burns through to a live Undo delete card at 100%.
Starting canvas…
Show the code two drawable cards, button-rect SDF, FBM burn shader, quench state and hit-box sync
- Two live drawable cards in one canvas.
#burn-cardholds editable controls and#btn-delete;#deleted-cardsits behind it asinertHTML until charge hits 100%. - Measure
#btn-deleteinside#burn-card. WalksoffsetLeftandoffsetTopup to#burn-cardsouOriginRectmatches the rendered button border box and corner distance. - FBM and cellular ember burn shader. Computes rounded-box distance from
uOriginRect, warps with 4-octave FBM and thermal updraft, chars ahead of the flame rim and raises sparks over the transparent void. - Hold, quench and reduced-motion state machine. Charges over 1.4 s on pointer or keyboard hold, cools back to zero on early release, and switches to a calm radial wipe without turbulence under reduced motion.
- Hit-box sync with
geometryUnit(). Flipsinert, moves the inactive card offstage withupdateElementGeometry()and togglesdataset.hitTickso#btn-undotakes clicks at 100%. - Five-argument 2D and plain-HTML fallbacks. Clips an expanding radial burn ring over
#burn-cardwith five-argumentdrawElementImage(), or moves both cards into plain HTML if the context is lost.
How it works
This builds on Hold to Delete by Keshav Bagaade. Instead of painting a static snapshot, both the editable card and the recovery card stay live DOM inside one <canvas content="drawable" layoutsubtree> rendered through ElementGL.
- Origin from the button box:
measureButtonRect()walksoffsetLeftandoffsetTopfrom#btn-deleteup to#burn-cardand computes the farthest corner SDF distance (uMaxDist). InBURN_FRAG, the rounded-box SDFboxSdstarts at zero right along the button's CSS border, so even at 4% charge a scorching corona hugs the button before eating outward. - Live DOM stays editable mid-burn: typing in the key title or notes, toggling scope pills or pressing Archive triggers a
paintevent for#burn-card. The listener uploads only the changed element withgl.texElementSubImage2D(), so new letters appear inside the unburnt paper and char as you scrub past them. - Quench vs commit: releasing pointer or Space/Enter before 1.4 s keeps
deleted = falseand coolschargeback to zero at 1.65 units per second, leaving everything you typed intact. Completing 100% marks#burn-cardinertand offstage, callsupdateElementGeometry()scaled bygeometryUnit(), togglesdataset.hitTickand hands pointer and keyboard focus to Undo delete. - Touch scroll and reduced motion: only
#btn-deleteusestouch-action: none(with context menu suppressed on long press) so normal scrolling over the rest of the card still works on a phone. Whenprefers-reduced-motion: reduceis set, the shader skips FBM turbulence, heat shimmer and sparks and steps the circular progress ring cleanly. - Fallbacks: without WebGL 2
texElementSubImage2D(), the canvas falls back to a 2D context clipping a radial burn hole over five-argumentdrawElementImage(). Onwebglcontextlostor unsupported browsers, both cards move into plain HTML until restored.
Live checks
Each check builds its own isolated fixture on testStage() and retires its canvas when finished. The visible demo above isn't touched.
| Result | Experiment | Detail |
|---|
Findings
Not verified yet in headless Chromium 157 or Chrome 159 on Android. Tap "Run these 5 checks" above to measure this browser.
- Not verified yet: live
texElementSubImage2D()ember shader rendering, ray-sampled char and flame front values atcharge = 0.55,updateElementGeometry()hit-testing on#btn-undo, touch long-press stability at 412 px andwebglcontextlostrecovery in Chromium 157 or Chrome 159 on Android. - Button-box coordinates vs intermediate flex rows: putting
position: relativeonly on#burn-card(and keeping flex rowsposition: static) letsoffsetLeftandoffsetTopmap straight to texture pixels without waiting ongetBoundingClientRect()during layout changes. - Premultiplied transparency behind the flame front: fading rising spark particles inside
burnGap > -0.20keeps the burned void deep behind the front at strictalpha = 0so the recovery card underneath shows cleanly and shader tests can verify transparency inside the button rectangle. - In-card DOM updates throttled to 5% steps: updating the card's internal percentage badge and progress bar every 5% instead of every 16 ms avoids repainting the DOM on every animation frame while keeping the WebGL flame running at display refresh rate.