5cdd69d7d9
- Add ResizeObserver (JS observeResize/unobserveResize + C# OnWidthChanged)
so _elementWidth stays current after window resize, fixing hover indicator drift
- Move _isSeeking = true before capturePointer await so a fast mobile tap
that fires pointerup mid-await still commits the seek
- Replace all Duration!.Value null-forgiving dereferences with explicit
Duration is > 0 guards in all four pointer event handlers
- Silence post-dispose resize callback rejections with .catch(() => {})
28 lines
1.0 KiB
JavaScript
28 lines
1.0 KiB
JavaScript
// Geometry helpers for WaveformSeeker. Deliberately tiny and standalone — this is NOT part of
|
|
// the TypeScript audio bundle (DeepDrftPublic/Interop/audio → wwwroot/js/audio). Loaded lazily as
|
|
// an ES module by the component via IJSObjectReference, so it adds no global script tag.
|
|
|
|
export function getWidth(element) {
|
|
return element ? element.getBoundingClientRect().width : 0;
|
|
}
|
|
|
|
export function capturePointer(element, pointerId) {
|
|
// setPointerCapture keeps a drag tracking even when the pointer leaves the element bounds.
|
|
element?.setPointerCapture?.(pointerId);
|
|
}
|
|
|
|
export function observeResize(element, dotNetRef) {
|
|
if (!element || typeof ResizeObserver === 'undefined') return null;
|
|
const observer = new ResizeObserver(entries => {
|
|
for (const entry of entries) {
|
|
dotNetRef.invokeMethodAsync('OnWidthChanged', entry.contentRect.width).catch(() => {});
|
|
}
|
|
});
|
|
observer.observe(element);
|
|
return observer;
|
|
}
|
|
|
|
export function unobserveResize(observer) {
|
|
observer?.disconnect();
|
|
}
|