Stories: read whether the story was playing before the press stops it

The director's own pointerdown listener, added first, stops a run whose
camera it drives before Stories heard the press, so the tap still played
the story again. Stories now reads the press in the capture phase, and
its tap listeners are removed on teardown.
This commit is contained in:
Sameh Khamis committed 2026-11-16 14:13:06 -08:00
1 parent 40f537a8b9
commit 78b8d8dc78
2 files changed
+24 -7

No files matched your search

+5 -3
View File
@@ -745,7 +745,8 @@ export function createStoriesController({
let downAt = null;
// Whether the story was playing when the tap began: a camera move the
// scene drives frame by frame stops on the press itself, before the tap
// ends, and that tap still means pause.
// ends, and that tap still means pause. The press is read in the capture
// phase, before the director's own listener can stop the run.
let playingAtDown = false;
const onDown = (e) => {
downAt = [e.clientX, e.clientY];
@@ -768,7 +769,7 @@ export function createStoriesController({
store.bigPlay = true;
} else player.play();
};
canvas.addEventListener('pointerdown', onDown);
canvas.addEventListener('pointerdown', onDown, true);
canvas.addEventListener('pointerup', onUp);
/** @returns {boolean} False when the camera is not free (Cockpit). */
@@ -1237,7 +1238,8 @@ export function createStoriesController({
useInstalledScenes(null);
removeEventListener('popstate', onPopState);
removeEventListener('popstate', onLandingCapture, true);
canvas.removeEventListener('pointerdown', onDown);
canvas.removeEventListener('pointerdown', onDown, true);
canvas.removeEventListener('pointerup', onUp);
canvas.removeEventListener('pointerdown', onExploreInput);
canvas.removeEventListener('pointerup', onExploreInput);
canvas.removeEventListener('pointercancel', onExploreInput);