Resize proxy function

This commit is contained in:
Ethan O'Brien 2023-07-08 19:12:55 -05:00
parent 36d2d61740
commit 1c6b6d0ad1

View file

@ -767,6 +767,13 @@ class EmulatorJS {
} }
this.callEvent("start"); this.callEvent("start");
} }
onResize() {
this.handleResize();
setTimeout(this.handleResize.bind(this), 50);
setTimeout(this.handleResize.bind(this), 100);
setTimeout(this.handleResize.bind(this), 500);
setTimeout(this.handleResize.bind(this), 1000);
}
bindListeners() { bindListeners() {
this.createContextMenu(); this.createContextMenu();
this.createBottomMenuBar(); this.createBottomMenuBar();
@ -777,7 +784,7 @@ class EmulatorJS {
this.addEventListener(this.elements.parent, "mousedown touchstart", (e) => { this.addEventListener(this.elements.parent, "mousedown touchstart", (e) => {
if (document.activeElement !== this.elements.parent) this.elements.parent.focus(); if (document.activeElement !== this.elements.parent) this.elements.parent.focus();
}) })
this.addEventListener(window, "resize", this.handleResize.bind(this)); this.addEventListener(window, "resize", this.onResize.bind(this));
//this.addEventListener(window, "blur", e => console.log(e), true); //TODO - add "click to make keyboard keys work" message? //this.addEventListener(window, "blur", e => console.log(e), true); //TODO - add "click to make keyboard keys work" message?
this.gamepad = new GamepadHandler(); //https://github.com/ethanaobrien/Gamepad this.gamepad = new GamepadHandler(); //https://github.com/ethanaobrien/Gamepad
this.gamepad.on('connected', (e) => { this.gamepad.on('connected', (e) => {
@ -1293,6 +1300,7 @@ class EmulatorJS {
screen.orientation.lock(this.getCore(true) === "nds" ? "portrait" : "landscape").catch(e => {});; screen.orientation.lock(this.getCore(true) === "nds" ? "portrait" : "landscape").catch(e => {});;
} catch(e) {} } catch(e) {}
} }
this.onResize();
}); });
const exit = addButton("Exit Fullscreen", '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M215.1 272h-136c-12.94 0-24.63 7.797-29.56 19.75C45.47 303.7 48.22 317.5 57.37 326.6l30.06 30.06l-78.06 78.07c-12.5 12.5-12.5 32.75-.0012 45.25l22.62 22.62c12.5 12.5 32.76 12.5 45.26 .0013l78.06-78.07l30.06 30.06c6.125 6.125 14.31 9.367 22.63 9.367c4.125 0 8.279-.7891 12.25-2.43c11.97-4.953 19.75-16.62 19.75-29.56V296C239.1 282.7 229.3 272 215.1 272zM296 240h136c12.94 0 24.63-7.797 29.56-19.75c4.969-11.97 2.219-25.72-6.938-34.87l-30.06-30.06l78.06-78.07c12.5-12.5 12.5-32.76 .0002-45.26l-22.62-22.62c-12.5-12.5-32.76-12.5-45.26-.0003l-78.06 78.07l-30.06-30.06c-9.156-9.141-22.87-11.84-34.87-6.937c-11.97 4.953-19.75 16.62-19.75 29.56v135.1C272 229.3 282.7 240 296 240z"/></svg>', () => { const exit = addButton("Exit Fullscreen", '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M215.1 272h-136c-12.94 0-24.63 7.797-29.56 19.75C45.47 303.7 48.22 317.5 57.37 326.6l30.06 30.06l-78.06 78.07c-12.5 12.5-12.5 32.75-.0012 45.25l22.62 22.62c12.5 12.5 32.76 12.5 45.26 .0013l78.06-78.07l30.06 30.06c6.125 6.125 14.31 9.367 22.63 9.367c4.125 0 8.279-.7891 12.25-2.43c11.97-4.953 19.75-16.62 19.75-29.56V296C239.1 282.7 229.3 272 215.1 272zM296 240h136c12.94 0 24.63-7.797 29.56-19.75c4.969-11.97 2.219-25.72-6.938-34.87l-30.06-30.06l78.06-78.07c12.5-12.5 12.5-32.76 .0002-45.26l-22.62-22.62c-12.5-12.5-32.76-12.5-45.26-.0003l-78.06 78.07l-30.06-30.06c-9.156-9.141-22.87-11.84-34.87-6.937c-11.97 4.953-19.75 16.62-19.75 29.56v135.1C272 229.3 282.7 240 296 240z"/></svg>', () => {
if (document.exitFullscreen) { if (document.exitFullscreen) {
@ -1311,6 +1319,7 @@ class EmulatorJS {
screen.orientation.unlock(); screen.orientation.unlock();
} catch(e) {} } catch(e) {}
} }
this.onResize();
}); });
exit.style.display = "none"; exit.style.display = "none";