mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
Street Level photo viewer: fresh elements per mount, and one viewer drawn
Fixes from review of the move to StreetLevelPhotoViewer: - Each mount and each panorama canvas now takes a key no viewer reuses, and the view keys its root by the mount. Before, switching KartaView and Panoramax in one tick let Vue patch the old viewer's canvas, whose destroyed renderer had lost its context, into the new one, so 360° photos fell back to their front view. - Of the viewers mounting in the host, the view draws the one mounted last, by mount key (photoViewers.js, which subscribePhotoViewer() now uses), whatever order they present in. A viewer still mounting when a later one is drawn is superseded: it unmounts and its mount fails as closed, rather than staying pending and being drawn once the later one goes. - A panorama's first image is uploaded once the view has drawn its canvas shown (the view hands the canvas back on every draw), so it is never sized into a hidden canvas. - The tests' fake view now draws as Vue does: once per tick with the final value, keeping elements while their keys are unchanged and handing every element back on each draw. StreetLevelPhotoViewer.test.mjs covers the switch in one tick and the overtaken mount with the real view. - The guard test's check that the photo viewer writes no DOM covers inserting, moving, removing and replacing elements, attributes, classes, styles and the hidden, disabled and text properties. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
766364f691
commit
2a0e21774b
17 files changed
+340
-107
No files matched your search
@@ -595,21 +595,30 @@ test('a panorama reopened after a lost context waits for the view’s fresh canv
|
||||
};
|
||||
},
|
||||
});
|
||||
// A view that draws a replacement canvas a while after it is asked.
|
||||
// A view that draws on a microtask, as Vue does, handing its canvas back
|
||||
// each time, but draws a replacement canvas only a while after it is
|
||||
// asked.
|
||||
let shown = null;
|
||||
let canvas = { name: 'canvas', clientWidth: 400 };
|
||||
let late = null;
|
||||
viewer.subscribeView((view) => {
|
||||
if (view && !shown) {
|
||||
for (const name of ['root', 'picture', 'prev', 'next'])
|
||||
view.actions.attach(name, { name, clientWidth: 400 });
|
||||
view.actions.attach('canvas', { name: 'canvas 0', clientWidth: 400 });
|
||||
} else if (view && view.canvasKey !== shown.canvasKey)
|
||||
late = () =>
|
||||
view.actions.attach('canvas', {
|
||||
name: `canvas ${view.canvasKey}`,
|
||||
clientWidth: 400,
|
||||
});
|
||||
const first = view && !shown;
|
||||
const replaced = view && shown && view.canvasKey !== shown.canvasKey;
|
||||
shown = view;
|
||||
if (!view) return;
|
||||
queueMicrotask(() => {
|
||||
if (first)
|
||||
for (const name of ['root', 'picture', 'prev', 'next'])
|
||||
view.actions.attach(name, { name, clientWidth: 400 });
|
||||
if (replaced) {
|
||||
canvas = null;
|
||||
late = () => {
|
||||
canvas = { name: 'canvas again', clientWidth: 400 };
|
||||
shown.actions.attach('canvas', canvas);
|
||||
};
|
||||
}
|
||||
if (canvas) view.actions.attach('canvas', canvas);
|
||||
});
|
||||
});
|
||||
await viewer.mount({});
|
||||
await viewer.open('a');
|
||||
@@ -623,7 +632,7 @@ test('a panorama reopened after a lost context waits for the view’s fresh canv
|
||||
await opening;
|
||||
assert.deepEqual(
|
||||
canvases.map((canvas) => canvas.name),
|
||||
['canvas 0', 'canvas 1'],
|
||||
['canvas', 'canvas again'],
|
||||
);
|
||||
assert.equal(shown.kind, 'pano', 'not the front view');
|
||||
});
|
||||
Reference in new issue
Block a user