mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
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:
1 parent
40f537a8b9
commit
78b8d8dc78
2 files changed
+24
-7
No files matched your search
@@ -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);
|
||||
|
||||
@@ -783,7 +783,24 @@ test('a story opened while the scene tears down is not undone by the late restor
|
||||
});
|
||||
|
||||
test('a tap pauses a story whose camera move stopped on the press', async () => {
|
||||
const { controller, store, director, canvas } = setup();
|
||||
setActivePinia(createPinia());
|
||||
history.replaceState(null, '', '/?x=1#v=2&lat=1');
|
||||
const store = useStoriesStore();
|
||||
const scene = fakeScene();
|
||||
const { canvas } = scene;
|
||||
// As in the app, the director listens for the press before Stories does,
|
||||
// and stopping its run publishes a stopped clock at once.
|
||||
canvas.addEventListener('pointerdown', () => {
|
||||
store.playback = { ...store.playback, playing: false };
|
||||
});
|
||||
const director = fakeDirector();
|
||||
const controller = createStoriesController({
|
||||
viewer: scene.viewer,
|
||||
director,
|
||||
store,
|
||||
clock: fakeClock(),
|
||||
});
|
||||
store.connect(controller, listStories());
|
||||
controller.openStory('gev:flights-radar');
|
||||
await tick(20);
|
||||
let starts = 0;
|
||||
@@ -793,9 +810,7 @@ test('a tap pauses a story whose camera move stopped on the press', async () =>
|
||||
};
|
||||
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 };
|
||||
assert.equal(store.playback.playing, false, 'the press stopped the run');
|
||||
canvas.dispatchEvent(new Event('pointerup'));
|
||||
await tick(20);
|
||||
assert.equal(starts, 0, 'the tap does not play it again');
|
||||
|
||||
Reference in new issue
Block a user