mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Address Stories review feedback
This commit is contained in:
1 parent
2edcd5bc69
commit
fec84dbf78
48 files changed
+783
-232
No files matched your search
@@ -37,6 +37,7 @@ export class SceneControls {
|
||||
// The SceneShotList view renders the rows and the panel its buttons;
|
||||
// their actions come back here.
|
||||
this.storeToken = store.attach({
|
||||
selectScene: (id) => this.run('selectScene', id),
|
||||
select: (id) => {
|
||||
this.run('selectShot', id);
|
||||
if (this.destroyed) return;
|
||||
|
||||
@@ -862,7 +862,7 @@ test('Stories tag chips and THUMBNAIL follow the current scene', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('the real director captures into a new scene from an empty panel', async () => {
|
||||
test('authoring can reopen a saved empty draft and capture from an empty panel', async () => {
|
||||
const f = fixture();
|
||||
const previousStorage = globalThis.localStorage;
|
||||
let saved = null;
|
||||
@@ -873,7 +873,14 @@ test('the real director captures into a new scene from an empty panel', async ()
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: {
|
||||
getItem: () => JSON.stringify({ version: 3, scenes: f.state.scenes }),
|
||||
getItem: () =>
|
||||
JSON.stringify({
|
||||
version: 3,
|
||||
scenes: [
|
||||
...f.state.scenes,
|
||||
{ id: 'empty-draft', title: 'Empty draft', shots: [] },
|
||||
],
|
||||
}),
|
||||
setItem: (_key, value) => {
|
||||
saved = JSON.parse(value);
|
||||
},
|
||||
@@ -896,6 +903,23 @@ test('the real director captures into a new scene from an empty panel', async ()
|
||||
);
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'No scene yet');
|
||||
const drafts = document.getElementById('empty-scene-select');
|
||||
assert.ok(drafts);
|
||||
drafts.value = 'empty-draft';
|
||||
drafts.dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'Empty draft');
|
||||
assert.equal(
|
||||
director.draftScenes().some(({ id }) => id === 'empty-draft'),
|
||||
false,
|
||||
);
|
||||
window.confirm = () => true;
|
||||
f.elements.delete.click();
|
||||
await nextTick();
|
||||
assert.equal(
|
||||
saved.scenes.some(({ id }) => id === 'empty-draft'),
|
||||
false,
|
||||
);
|
||||
window.prompt = () => 'Harbour';
|
||||
f.elements.capture.click();
|
||||
await nextTick();
|
||||
|
||||
@@ -3,6 +3,7 @@ import { computed, markRaw, shallowRef } from 'vue';
|
||||
|
||||
/**
|
||||
* @typedef {object} SceneRowHandlers
|
||||
* @property {(sceneId: string) => void} selectScene
|
||||
* @property {(shotId: string) => void} select
|
||||
* @property {(sceneId: string, shotId: string, title: string) => void} rename
|
||||
* @property {(sceneId: string, shotId: string) => void} load
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import { createPinia } from 'pinia';
|
||||
import { useStoriesStore } from './stores/stories.js';
|
||||
import { storyById } from '../stories/catalog.js';
|
||||
import StoryScreen from './views/stories/StoryScreen.vue';
|
||||
|
||||
test('the story screen previews a drag and seeks once on release', async (t) => {
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const store = useStoriesStore(pinia);
|
||||
const builtIn = storyById('gev:flights-radar');
|
||||
const first = builtIn.chapters[0];
|
||||
const story = {
|
||||
...builtIn,
|
||||
durationMs: 24000,
|
||||
chapters: [first, { ...first, id: 'second', wallMs: 12000 }],
|
||||
};
|
||||
const seeks = [];
|
||||
store.connect(
|
||||
{
|
||||
seek(ms) {
|
||||
seeks.push(ms);
|
||||
store.playback.wallMs = ms;
|
||||
},
|
||||
},
|
||||
[story],
|
||||
);
|
||||
const app = createApp(StoryScreen, { story }).use(pinia);
|
||||
app.mount(host);
|
||||
t.after(() => {
|
||||
app.unmount();
|
||||
host.remove();
|
||||
});
|
||||
|
||||
const track = host.querySelector('#tlTrack');
|
||||
track.getBoundingClientRect = () => ({ left: 0, width: 400 });
|
||||
const pointer = (type, clientX) =>
|
||||
track.dispatchEvent(new PointerEvent(type, { pointerId: 1, clientX }));
|
||||
const progress = () => Number(track.getAttribute('aria-valuenow'));
|
||||
const before = progress();
|
||||
pointer('pointerdown', 45);
|
||||
pointer('pointermove', 60);
|
||||
pointer('pointermove', 80);
|
||||
await nextTick();
|
||||
const preview = progress();
|
||||
assert.ok(preview > before);
|
||||
assert.deepEqual(seeks, []);
|
||||
pointer('pointerup', 80);
|
||||
await nextTick();
|
||||
assert.equal(seeks.length, 1);
|
||||
assert.equal(progress(), preview);
|
||||
assert.equal(progress(), Math.round((seeks[0] / story.durationMs) * 100));
|
||||
|
||||
pointer('pointerdown', 300);
|
||||
await nextTick();
|
||||
assert.notEqual(progress(), preview);
|
||||
pointer('pointercancel', 300);
|
||||
await nextTick();
|
||||
assert.equal(progress(), preview);
|
||||
assert.equal(seeks.length, 1);
|
||||
track.dispatchEvent(new KeyboardEvent('keydown', { key: 'End' }));
|
||||
await nextTick();
|
||||
assert.equal(track.querySelector('.tl-seg.now')?.dataset.k, '1');
|
||||
track.dispatchEvent(new KeyboardEvent('keydown', { key: '[' }));
|
||||
await nextTick();
|
||||
assert.equal(track.querySelector('.tl-seg.now')?.dataset.k, '0');
|
||||
assert.deepEqual(seeks.slice(1), [23990, first.wallMs + 1]);
|
||||
});
|
||||
@@ -177,6 +177,11 @@
|
||||
color: var(--scene-quiet);
|
||||
}
|
||||
|
||||
#empty-scene-select {
|
||||
flex: 1 1 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* A translated action longer than its button wraps inside the button instead
|
||||
of running past it. English keeps its one-line buttons. */
|
||||
html:not([lang='en']) #scene-panel .scene-controls .scene-btn {
|
||||
|
||||
@@ -207,7 +207,7 @@ body.ui-clean-view #gev-stories .gs-pop {
|
||||
z-index: 1201;
|
||||
bottom: 110px;
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
@media (max-width: 720px) {
|
||||
#gev-stories .gs-pop {
|
||||
left: 12px;
|
||||
right: 12px !important;
|
||||
|
||||
+22
-22
@@ -360,7 +360,7 @@
|
||||
bottom: 1px;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .st-map .ov-clock {
|
||||
padding: 3px 24px 3px 4px;
|
||||
}
|
||||
@@ -389,7 +389,7 @@
|
||||
bottom: 92px;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .h-top {
|
||||
padding: 16px 12px 0 18px;
|
||||
align-items: center;
|
||||
@@ -549,7 +549,7 @@
|
||||
top: calc(var(--hh) + 64px);
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .scr-explore,
|
||||
#gev-stories .scr-story {
|
||||
--hh: 62px;
|
||||
@@ -936,7 +936,7 @@
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .ex-body,
|
||||
#gev-stories .ex-body[data-side='right'] {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
@@ -1330,7 +1330,7 @@
|
||||
height: 18px;
|
||||
filter: drop-shadow(0 0 6px rgba(0, 246, 255, 0.45));
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .h-toast {
|
||||
bottom: 76px;
|
||||
flex-wrap: wrap;
|
||||
@@ -2115,7 +2115,7 @@
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .timeline {
|
||||
padding-top: 20px;
|
||||
}
|
||||
@@ -2473,7 +2473,7 @@
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .st-body,
|
||||
#gev-stories .scr-story[data-chapters='timeline'] .st-body,
|
||||
#gev-stories .scr-story.expanded .st-body {
|
||||
@@ -3140,7 +3140,7 @@
|
||||
#gev-stories .m-only-search {
|
||||
display: none;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .ex-msearch {
|
||||
display: none;
|
||||
}
|
||||
@@ -3173,7 +3173,7 @@
|
||||
border-radius: var(--panel-radius) 0 0 var(--panel-radius);
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .ex-body .ex-feed,
|
||||
#gev-stories .ex-body[data-side='right'] .ex-feed {
|
||||
border-radius: 18px 18px 0 0;
|
||||
@@ -3273,7 +3273,7 @@
|
||||
#gev-stories .thumb-play:hover {
|
||||
border-color: #fff;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .thumb-play {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
@@ -3301,7 +3301,7 @@
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4) !important;
|
||||
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .thumb-play {
|
||||
border-radius: 9px !important;
|
||||
}
|
||||
@@ -3318,7 +3318,7 @@
|
||||
#gev-stories .thumb-play {
|
||||
z-index: 1;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .pin[aria-pressed='true'] .pin-thumb {
|
||||
display: block;
|
||||
width: 42px;
|
||||
@@ -3422,7 +3422,7 @@
|
||||
.pin-thumb::after {
|
||||
opacity: 0 !important;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .scr-explore .pins .pin[aria-pressed='true'] .pin-thumb {
|
||||
width: auto;
|
||||
height: 38px;
|
||||
@@ -3456,7 +3456,7 @@
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .scr-explore .pins .pin[aria-pressed='true'] .pin-thumb {
|
||||
padding: 0 16px !important;
|
||||
justify-content: center;
|
||||
@@ -3470,7 +3470,7 @@
|
||||
margin: 0 !important;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .card .c-layers,
|
||||
#gev-stories .card[aria-pressed='true'] .c-layers {
|
||||
display: none !important;
|
||||
@@ -3493,7 +3493,7 @@
|
||||
0 0 0 0 rgba(0, 212, 255, 0);
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .scr-explore .pins .pin[aria-pressed='true'] .pin-lbl,
|
||||
#gev-stories .scr-explore .pins .pin[aria-pressed='true'] .pin-dot {
|
||||
visibility: hidden;
|
||||
@@ -3529,7 +3529,7 @@
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .card .thumb {
|
||||
grid-row: 1 / 3 !important;
|
||||
}
|
||||
@@ -3552,7 +3552,7 @@
|
||||
#gev-stories #scrExplore .s-head .s-msearch {
|
||||
display: none !important;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories #scrExplore .s-head .h-right .tbtn.hide-m:not(.accent) {
|
||||
display: grid !important;
|
||||
place-items: center;
|
||||
@@ -3653,12 +3653,12 @@
|
||||
#gev-stories .ex-tools .fh-search:focus-within kbd {
|
||||
display: none;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .ex-tools .fh-search kbd {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories #tlHead {
|
||||
display: none !important;
|
||||
}
|
||||
@@ -3820,7 +3820,7 @@ body.stories-mode:not(#gs-a):not(#gs-b) #gev-credits {
|
||||
}
|
||||
/* On a phone the line wraps and shrinks to stay on screen, as the phone
|
||||
shell does outside recording mode. */
|
||||
@media (max-width: 700px) {
|
||||
@media (max-width: 720px) {
|
||||
body.stories-mode:not(#gs-a):not(#gs-b) #cesium-credits,
|
||||
body.stories-mode:not(#gs-a):not(#gs-b) #gev-credits {
|
||||
width: calc((100vw - 20px) / 0.8) !important;
|
||||
@@ -3839,7 +3839,7 @@ body.stories-mode:not(#gs-a):not(#gs-b) #gev-credits {
|
||||
#gev-stories .scr-story .ov-legend {
|
||||
bottom: 68px !important;
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
@media (max-width: 720px) {
|
||||
#gev-stories .scr-story .st-map .ov-clock {
|
||||
margin-bottom: 26px;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
@@ -24,6 +25,7 @@ const { toolbar, dialog } = storeToRefs(useSceneSharingStore());
|
||||
// answers the buttons through the store.
|
||||
const scenes = useSceneStore();
|
||||
const { panel: scene, currentScene } = storeToRefs(scenes);
|
||||
const emptyScenes = computed(() => scenes.scenes.filter(({ shots }) => !shots.length));
|
||||
const off = (name) => scene.value?.disabled[name] ?? false;
|
||||
// The current scene's Stories tags; a chip not yet on is off at the limit.
|
||||
const tagOn = (tag) => currentScene.value?.storyTags?.includes(tag) ?? false;
|
||||
@@ -75,6 +77,17 @@ async function importChosen(event) {
|
||||
<p class="scene-step-heading">{{ t('SCENE') }}</p>
|
||||
<div class="scene-controls">
|
||||
<p id="scene-name" :class="{ 'scene-name-empty': !currentScene }">{{ currentScene?.title ?? t('No scene yet') }}</p>
|
||||
<select
|
||||
v-if="emptyScenes.length"
|
||||
id="empty-scene-select"
|
||||
:aria-label="t('Empty drafts')"
|
||||
:disabled="off('new')"
|
||||
:value="currentScene?.shots.length === 0 ? currentScene.id : ''"
|
||||
@change="scenes.act('selectScene', $event.target.value)"
|
||||
>
|
||||
<option value="" disabled>{{ t('Empty drafts') }}</option>
|
||||
<option v-for="draft in emptyScenes" :key="draft.id" :value="draft.id">{{ draft.title }}</option>
|
||||
</select>
|
||||
<UiButton id="scene-new-btn" type="button" :disabled="off('new')" @click="scenes.act('create')" class="gev-action-button scene-btn" :title="t('Start a new, empty scene')">{{ t('NEW SCENE') }}</UiButton>
|
||||
<UiButton tone="alert" id="scene-delete-btn" type="button" :disabled="off('delete')" @click="scenes.act('deleteScene')" class="gev-action-button gev-action-button--danger scene-btn scene-btn-danger" :title="t('Delete this scene and all of its shots')">{{ t('DELETE') }}</UiButton>
|
||||
</div>
|
||||
|
||||
@@ -284,9 +284,23 @@ onBeforeUnmount(() => {
|
||||
removeEventListener('keydown', onKey, true);
|
||||
unguardKeys?.();
|
||||
});
|
||||
watch(mode, (m) => {
|
||||
if (m === 'closed') requestAnimationFrame(placeEntry);
|
||||
else popOpen.value = false;
|
||||
let returnFocus = null;
|
||||
watch(mode, (m, previous) => {
|
||||
if (m === 'closed') {
|
||||
requestAnimationFrame(placeEntry);
|
||||
nextTick(() => {
|
||||
if (mode.value !== 'closed') return;
|
||||
const entry = rootEl.value?.querySelector('#hStories');
|
||||
const target = returnFocus?.isConnected && returnFocus !== document.body
|
||||
? returnFocus
|
||||
: entry;
|
||||
target?.focus({ preventScroll: true });
|
||||
returnFocus = null;
|
||||
});
|
||||
} else {
|
||||
if (previous === 'closed') returnFocus = document.activeElement;
|
||||
popOpen.value = false;
|
||||
}
|
||||
});
|
||||
// Each screen (and each story, keyed) mounts its own map slot.
|
||||
watch([mode, storyId], () => nextTick(watchCredit));
|
||||
|
||||
@@ -172,7 +172,7 @@ function headerSearch() {
|
||||
const feedEl = ref(null);
|
||||
function pick(id) {
|
||||
if (picked.value === id) return;
|
||||
if (innerWidth <= 700 && feedSnap.value === 'list') setFeed('split');
|
||||
if (innerWidth <= 720 && feedSnap.value === 'list') setFeed('split');
|
||||
store.controller.pick(id);
|
||||
nextTick(() =>
|
||||
feedEl.value
|
||||
@@ -209,20 +209,13 @@ const pickedStory = computed(() =>
|
||||
picked.value ? store.byId(picked.value) : null,
|
||||
);
|
||||
|
||||
// ── Pins: projected in window pixels, placed inside the map area ──
|
||||
const pinsEl = ref(null);
|
||||
const origin = ref({ x: 0, y: 0 });
|
||||
function measure() {
|
||||
const r = pinsEl.value?.getBoundingClientRect();
|
||||
if (r) origin.value = { x: r.left, y: r.top };
|
||||
}
|
||||
watch(pins, measure);
|
||||
// ── Pins: projected into the map area ──
|
||||
const placedPins = computed(() =>
|
||||
pins.value.map((p) => ({
|
||||
...p,
|
||||
story: store.byId(p.id),
|
||||
style: {
|
||||
transform: `translate(${p.x - origin.value.x}px, ${p.y - origin.value.y}px) translate(-50%, -100%)`,
|
||||
transform: `translate(${p.x}px, ${p.y}px) translate(-50%, -100%)`,
|
||||
},
|
||||
})),
|
||||
);
|
||||
@@ -240,7 +233,7 @@ function setFeed(snap) {
|
||||
}
|
||||
let fd = null;
|
||||
function onHeadDown(e) {
|
||||
if (innerWidth > 700 || e.target.closest('.fh-tools')) return;
|
||||
if (innerWidth > 720 || e.target.closest('.fh-tools')) return;
|
||||
try {
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
} catch {
|
||||
@@ -358,7 +351,7 @@ function onResizeReset() {
|
||||
}
|
||||
const bodyStyle = computed(() => ({
|
||||
'--feed-h': `${(feedH.value ?? FEED[feedSnap.value]) * 100}%`,
|
||||
...(innerWidth > 700
|
||||
...(innerWidth > 720
|
||||
? {
|
||||
'--feedw': `${feedW.value}px`,
|
||||
gridTemplateColumns: `${feedW.value}px minmax(0, 1fr)`,
|
||||
@@ -370,13 +363,10 @@ onMounted(() => {
|
||||
document.addEventListener('pointerdown', onDocDown);
|
||||
// On the window: the Stories keyboard guard stops keys before the document.
|
||||
addEventListener('keydown', onSlash, true);
|
||||
addEventListener('resize', measure);
|
||||
measure();
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('pointerdown', onDocDown);
|
||||
removeEventListener('keydown', onSlash, true);
|
||||
removeEventListener('resize', measure);
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
@@ -680,7 +670,7 @@ defineExpose({
|
||||
</aside>
|
||||
<div class="ex-map">
|
||||
<div class="map-slot"></div>
|
||||
<div id="pins" ref="pinsEl" class="pins">
|
||||
<div id="pins" class="pins">
|
||||
<button
|
||||
v-for="p in placedPins"
|
||||
:key="p.id"
|
||||
|
||||
@@ -39,6 +39,8 @@ async function share() {
|
||||
}
|
||||
// Long titles scroll gently so the whole name can be read.
|
||||
const mtitle = ref(null);
|
||||
const back = ref(null);
|
||||
const trail = ref(null);
|
||||
let observer = null;
|
||||
function fitTitle() {
|
||||
const el = mtitle.value;
|
||||
@@ -50,6 +52,10 @@ function fitTitle() {
|
||||
el.style.setProperty('--mq-dur', `${Math.max(5, (over + 22) / 22)}s`);
|
||||
}
|
||||
onMounted(() => {
|
||||
const target = back.value?.getClientRects().length
|
||||
? back.value
|
||||
: trail.value?.querySelector('button');
|
||||
target?.focus({ preventScroll: true });
|
||||
if (globalThis.ResizeObserver && mtitle.value) {
|
||||
observer = new ResizeObserver(fitTitle);
|
||||
observer.observe(mtitle.value);
|
||||
@@ -66,6 +72,7 @@ onBeforeUnmount(() => observer?.disconnect());
|
||||
<template>
|
||||
<header class="h-top s-head">
|
||||
<button
|
||||
ref="back"
|
||||
class="s-back glass"
|
||||
type="button"
|
||||
:aria-label="
|
||||
@@ -98,7 +105,7 @@ onBeforeUnmount(() => observer?.disconnect());
|
||||
</button>
|
||||
<span class="h-word" translate="no">GOD'S EYE <b>VIEW</b></span>
|
||||
</div>
|
||||
<nav class="h-tag s-trail" :aria-label="t('Breadcrumb')">
|
||||
<nav ref="trail" class="h-tag s-trail" :aria-label="t('Breadcrumb')">
|
||||
<template v-if="screen === 'explore'">
|
||||
<button type="button" @click="emit('home')">{{ t('Globe') }}</button>
|
||||
<span aria-hidden="true">/</span>
|
||||
|
||||
@@ -131,7 +131,7 @@ function setSheet(s) {
|
||||
setTimeout(() => store.controller.reframe(), 320);
|
||||
}
|
||||
function onHandleDown(e) {
|
||||
if (innerWidth > 700) return;
|
||||
if (innerWidth > 720) return;
|
||||
try {
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
} catch {
|
||||
|
||||
@@ -84,7 +84,7 @@ function goChapter(i) {
|
||||
}
|
||||
function goAnchor(ev) {
|
||||
store.controller.focusEvent(ev);
|
||||
if (innerWidth <= 700) sheet.value = 'half';
|
||||
if (innerWidth <= 720) sheet.value = 'half';
|
||||
}
|
||||
function bigPlayClick() {
|
||||
bigPlay.value = false;
|
||||
@@ -205,7 +205,7 @@ function pokeControls() {
|
||||
expanded.value &&
|
||||
playback.value.playing &&
|
||||
!playback.value.exploring &&
|
||||
innerWidth <= 700
|
||||
innerWidth <= 720
|
||||
)
|
||||
pokeTimer = setTimeout(() => (controlsHidden.value = true), 3000);
|
||||
}
|
||||
@@ -224,7 +224,7 @@ watch(
|
||||
if (!on || store.sheetHintSeen) return;
|
||||
hintTimers.push(
|
||||
setTimeout(() => {
|
||||
if (store.sheetHintSeen || innerWidth > 700 || sheet.value !== 'peek')
|
||||
if (store.sheetHintSeen || innerWidth > 720 || sheet.value !== 'peek')
|
||||
return;
|
||||
store.sheetHintSeen = true;
|
||||
sheetHint.value = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useStoriesStore } from '../../stores/stories.js';
|
||||
@@ -25,7 +25,8 @@ const { playback, muted, expanded } = storeToRefs(store);
|
||||
const dur = computed(
|
||||
() => playback.value.durationMs || props.story.durationMs || 1,
|
||||
);
|
||||
const tNow = computed(() => playback.value.wallMs);
|
||||
const previewMs = ref(null);
|
||||
const tNow = computed(() => previewMs.value ?? playback.value.wallMs);
|
||||
const pct = computed(() => clamp((tNow.value / dur.value) * 100, 0, 100));
|
||||
const k = computed(() => chapterAt(props.story, tNow.value));
|
||||
const chapters = computed(() => props.story.chapters);
|
||||
@@ -76,7 +77,12 @@ const segs = computed(() =>
|
||||
|
||||
// ── Readout ──
|
||||
const clock = computed(() =>
|
||||
clockText(props.story, tNow.value, playback.value.worldMs, k.value),
|
||||
clockText(
|
||||
props.story,
|
||||
tNow.value,
|
||||
previewMs.value == null ? playback.value.worldMs : null,
|
||||
k.value,
|
||||
),
|
||||
);
|
||||
const stampAt = (ms) => fmtDur(ms);
|
||||
const headTime = computed(() => `${fmtDur(tNow.value)} / ${fmtDur(dur.value)}`);
|
||||
@@ -84,18 +90,15 @@ const atEdge = computed(
|
||||
() => props.story.live && tNow.value >= dur.value - 600,
|
||||
);
|
||||
|
||||
// ── Scrubbing: magnetic chapter ticks, momentum, haptic ticks ──
|
||||
// ── Scrubbing: preview locally, seek the globe once on release ──
|
||||
const track = ref(null);
|
||||
const scrubbing = ref(false);
|
||||
const scrubbing = computed(() => previewMs.value !== null);
|
||||
const snap = ref(-1);
|
||||
const hovered = ref(-1);
|
||||
const ghost = ref(0);
|
||||
const bubbleAt = ref(null);
|
||||
let sc = null;
|
||||
let coastRaf = 0;
|
||||
let pipSnap = -1;
|
||||
const reduceMotion = () =>
|
||||
globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
|
||||
const haptic = () => {
|
||||
try {
|
||||
navigator.vibrate?.(3);
|
||||
@@ -105,10 +108,11 @@ const haptic = () => {
|
||||
};
|
||||
function trackAt(clientX) {
|
||||
const r = track.value.getBoundingClientRect();
|
||||
let u = clamp((clientX - r.left) / r.width, 0, 1);
|
||||
const width = r.width || 1;
|
||||
let u = clamp((clientX - r.left) / width, 0, 1);
|
||||
let snapped = -1;
|
||||
chapters.value.forEach((c, i) => {
|
||||
if (i && Math.abs(u - c.wallMs / dur.value) * r.width < 9) {
|
||||
if (i && Math.abs(u - c.wallMs / dur.value) * width < 9) {
|
||||
u = c.wallMs / dur.value;
|
||||
snapped = i;
|
||||
}
|
||||
@@ -141,31 +145,26 @@ function scrubTo(target) {
|
||||
haptic();
|
||||
sc.ch = ch;
|
||||
}
|
||||
seek(tt);
|
||||
previewMs.value = tt;
|
||||
snap.value = snapped;
|
||||
bubbleAt.value = tt;
|
||||
return snapped >= 0 || snapped <= -2 ? Math.max(0, snapped) : -1;
|
||||
}
|
||||
function onDown(e) {
|
||||
if (e.target.closest('.tl-pip')) return;
|
||||
if (sc || e.button !== 0 || e.target.closest('.tl-pip')) return;
|
||||
try {
|
||||
track.value.setPointerCapture(e.pointerId);
|
||||
} catch {
|
||||
/* nothing to capture */
|
||||
}
|
||||
cancelAnimationFrame(coastRaf);
|
||||
scrubbing.value = true;
|
||||
const r = trackAt(e.clientX);
|
||||
sc = {
|
||||
pointerId: e.pointerId,
|
||||
lastX: e.clientX,
|
||||
lastT: performance.now(),
|
||||
v: 0,
|
||||
ch: chapterAt(props.story, r.t),
|
||||
at: r.t,
|
||||
};
|
||||
seek(r.t);
|
||||
snap.value = r.snapped;
|
||||
bubbleAt.value = r.t;
|
||||
scrubTo(r.t);
|
||||
}
|
||||
function onMove(e) {
|
||||
if (!scrubbing.value) {
|
||||
@@ -184,47 +183,27 @@ function onMove(e) {
|
||||
bubbleAt.value = r.t;
|
||||
return;
|
||||
}
|
||||
if (sc.pointerId !== e.pointerId) return;
|
||||
// Slow drags are fine, fast drags coarse.
|
||||
const now = performance.now();
|
||||
const dx = e.clientX - sc.lastX;
|
||||
const dtm = Math.max(1, now - sc.lastT);
|
||||
const w = track.value.getBoundingClientRect().width || 1;
|
||||
const gain = clamp(0.25 + (Math.abs(dx) / dtm) * 1.1, 0.25, 2.5);
|
||||
const before = sc.at;
|
||||
sc.at = clamp(sc.at + (dx / w) * dur.value * gain, 0, dur.value - 10);
|
||||
scrubTo(sc.at);
|
||||
sc.v = (sc.at - before) / dtm;
|
||||
sc.lastX = e.clientX;
|
||||
sc.lastT = now;
|
||||
}
|
||||
function onUp() {
|
||||
scrubbing.value = false;
|
||||
function finishScrub(e) {
|
||||
if (sc?.pointerId !== e.pointerId) return;
|
||||
const at = previewMs.value;
|
||||
sc = null;
|
||||
previewMs.value = null;
|
||||
snap.value = -1;
|
||||
pipSnap = -1;
|
||||
if (
|
||||
!sc ||
|
||||
reduceMotion() ||
|
||||
Math.abs(sc.v) < 2 ||
|
||||
performance.now() - sc.lastT > 120
|
||||
) {
|
||||
sc = null;
|
||||
return;
|
||||
}
|
||||
// A release coasts with momentum, stopping on a chapter tick.
|
||||
let v = sc.v * 16;
|
||||
let at = sc.at;
|
||||
const coast = () => {
|
||||
at += v;
|
||||
const hit = scrubTo(at);
|
||||
v *= 0.92;
|
||||
if (hit >= 0 || Math.abs(v) < 20 || at <= 0 || at >= dur.value - 20) {
|
||||
snap.value = -1;
|
||||
sc = null;
|
||||
return;
|
||||
}
|
||||
coastRaf = requestAnimationFrame(coast);
|
||||
};
|
||||
coastRaf = requestAnimationFrame(coast);
|
||||
if (e.type === 'pointerup') seek(at);
|
||||
else bubbleAt.value = null;
|
||||
}
|
||||
function onLeave() {
|
||||
if (scrubbing.value) return;
|
||||
@@ -369,7 +348,6 @@ function jumpLive() {
|
||||
if (playback.value.exploring) store.controller.resume();
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => cancelAnimationFrame(coastRaf));
|
||||
defineExpose({ goChapter });
|
||||
</script>
|
||||
|
||||
@@ -410,8 +388,9 @@ defineExpose({ goChapter });
|
||||
:aria-valuetext="`${clock.big}, ${t('chapter')} ${k + 1}: ${chTitle(chapters[k])}`"
|
||||
@pointerdown="onDown"
|
||||
@pointermove="onMove"
|
||||
@pointerup="onUp"
|
||||
@pointercancel="onUp"
|
||||
@pointerup="finishScrub"
|
||||
@pointercancel="finishScrub"
|
||||
@lostpointercapture="finishScrub"
|
||||
@pointerleave="onLeave"
|
||||
@keydown="onKey"
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user