From 807e87273110ed691467141e5adb04087ee898e7 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Mon, 16 Nov 2026 14:00:09 -0800 Subject: [PATCH] Stories: a tap pauses a story whose camera move stopped on the press A camera move the scene drives frame by frame (an authored move, or a flight resumed partway) stops the run on pointerdown, so the story read as stopped when the tap ended and the tap played it again. The tap now goes by whether the story was playing when it began. --- src/stories/controller.js | 7 ++++++- src/stories/controller.test.mjs | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/stories/controller.js b/src/stories/controller.js index a61a850ca..247384365 100644 --- a/src/stories/controller.js +++ b/src/stories/controller.js @@ -743,8 +743,13 @@ export function createStoriesController({ // the picked story; on a phone, touching the map drops the context sheet // back to its peek. 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. + let playingAtDown = false; const onDown = (e) => { downAt = [e.clientX, e.clientY]; + playingAtDown = store.playback.playing; if (store.mode === 'story' && innerWidth <= 720 && store.sheet !== 'peek') store.sheet = 'peek'; }; @@ -758,7 +763,7 @@ export function createStoriesController({ return; } if (store.mode !== 'story' || !player) return; - if (store.playback.playing) { + if (playingAtDown || store.playback.playing) { player.pause(); store.bigPlay = true; } else player.play(); diff --git a/src/stories/controller.test.mjs b/src/stories/controller.test.mjs index 3f369f6e6..0c613420d 100644 --- a/src/stories/controller.test.mjs +++ b/src/stories/controller.test.mjs @@ -782,6 +782,32 @@ test('a story opened while the scene tears down is not undone by the late restor controller.destroy(); }); +test('a tap pauses a story whose camera move stopped on the press', async () => { + const { controller, store, director, canvas } = setup(); + controller.openStory('gev:flights-radar'); + await tick(20); + let starts = 0; + director.startScene = async () => { + starts += 1; + return { started: true }; + }; + store.playback = { ...store.playback, playing: true }; + canvas.dispatchEvent(new Event('pointerdown')); + // A camera move the scene drives frame by frame stops on the press, so the + // story already reads as stopped when the tap ends. + store.playback = { ...store.playback, playing: false }; + canvas.dispatchEvent(new Event('pointerup')); + await tick(20); + assert.equal(starts, 0, 'the tap does not play it again'); + assert.equal(store.bigPlay, true, 'it pauses'); + // A tap on a paused story plays it. + canvas.dispatchEvent(new Event('pointerdown')); + canvas.dispatchEvent(new Event('pointerup')); + await tick(20); + assert.equal(starts, 1); + controller.destroy(); +}); + test('Explore tours from story to story once idle, stops on a pick or a touch, and on Close', async (t) => { t.mock.timers.enable({ apis: ['setTimeout', 'Date'] }); const { controller, store, camera, canvas } = setup();