Skip to content

Commit 22997ba

Browse files
committed
fix
1 parent cfdf5f2 commit 22997ba

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

components/pano-scene.js

+7-12
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ export default class PanoScene extends HTMLElement {
5555
lp.addEventListener("change", e => this.#onPanoChange(e));
5656

5757
if (camera) { // crossfade
58+
this.append(lp, ...this.#near.values());
5859
let oldLp = this.#lp;
5960
lp.style.opacity = 0;
60-
this.append(lp, ...this.#near.values());
61-
await lpLoaded(lp);
62-
lp.mode = "pano";
63-
lp.camera = camera;
64-
crossfade(oldLp, lp);
61+
lp.addEventListener("load", _ => {
62+
lp.mode = "pano";
63+
lp.camera = camera;
64+
crossfade(oldLp, lp);
65+
});
6566
} else { // hard replace
6667
this.replaceChildren(lp, ...this.#near.values());
6768
}
@@ -91,6 +92,7 @@ export default class PanoScene extends HTMLElement {
9192
if (!(YAW_KEY in this.#item)) { return; }
9293

9394
const { mode, camera } = e.target;
95+
console.log(e, camera)
9496

9597
switch (mode) {
9698
case "pano":
@@ -114,10 +116,3 @@ function crossfade(oldLp, newLp) {
114116
oldLp.animate({opacity: [1, 0]}, duration).finished.then(_ => oldLp.remove());
115117
newLp.animate({opacity: [0, 1]}, {duration, fill:"both"}).finished.then(a => a.commitStyles());
116118
}
117-
118-
function lpLoaded(lp) {
119-
return new Promise((resolve, reject) => {
120-
lp.addEventListener("load", resolve);
121-
lp.addEventListener("error", reject);
122-
});
123-
}

0 commit comments

Comments
 (0)