fix(RadialKnob): real pointer capture via setPointerCapture interop

Switch initiator to @onpointerdown; capture the pointer on the knob element
through a new knob.ts helper so pointermove/up/cancel reach the knob even
when the cursor leaves the window. Accurate comment; IAsyncDisposable cleanup.
This commit is contained in:
daniel-c-harvey
2026-06-17 15:43:26 -04:00
parent 8a329aadcf
commit 3835d9f9c4
2 changed files with 75 additions and 14 deletions
@@ -0,0 +1,20 @@
/**
* knob - pointer capture helpers for RadialKnob.
*
* setPointerCapture / releasePointerCapture are not exposed via Blazor's
* ElementReference, so the component delegates here via JS interop.
* Both functions are no-ops when the element reference is stale (e.g. the
* component was disposed between the JS call and the microtask).
*/
/** Capture the pointer on the given element so pointermove/pointerup are
* delivered even when the cursor leaves the browser window. */
export function capturePointer(el: Element, pointerId: number): void {
(el as HTMLElement).setPointerCapture(pointerId);
}
/** Release a previously captured pointer. Called on pointercancel.
* pointerup releases capture implicitly, but we call this on cancel too. */
export function releasePointer(el: Element, pointerId: number): void {
(el as HTMLElement).releasePointerCapture(pointerId);
}