ignore throttle drag before first tap/click
Hunter
Friday, November 13th, 2026 at 11:27 PM
361 mode = acrossTravel >= upTravel ? 'throttle' : 'volume';
362 clearTimeout(pressTimer);
363 clearTimeout(holdTimer);
- row.classList.add(mode);
364 + // Browsers suspend audio until the first tap or click; a dragged touch
365 + // doesn't count. Ignore a throttle drag before then, as the tape can't play.
366 + if (mode === 'throttle' && audio.state !== 'running') mode = 'ignored';
367 + if (mode !== 'ignored') row.classList.add(mode);
368 if (mode === 'throttle') send('grab');
369 pressed = false;
370 }
371 if (mode === 'throttle') {
372 send('throttle', {change: (event.clientX - start.x) / THROTTLE_DRAG});
- } else {
373 + } else if (mode === 'volume') {
374 const change = (start.y - event.clientY) / row.clientHeight;
375 tape.volume = Math.min(MAX_VOLUME, Math.max(0, start.volume + change));
376 send('volume', {value: tape.volume});
380 const end = event => {
381 if (event.pointerId !== pointerId) return;
382 pointerId = null;
383 + // A touch only counts as a user gesture when it lifts without having moved,
384 + // so the resume on pointerdown fails if this touch is the first one.
385 + audio.resume();
386 clearTimeout(pressTimer);
387 clearTimeout(holdTimer);
388 row.classList.remove('grabbed', 'throttle', 'volume');