1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-23 03:29:39 +00:00

vcs: resize screen

This commit is contained in:
Steven Hugg 2020-10-07 15:56:38 -05:00
parent 3041b08ae0
commit bf6e399ce9
2 changed files with 13 additions and 2 deletions

View File

@ -1958,7 +1958,7 @@ function replaceURLState() {
function addPageFocusHandlers() {
var hidden = false;
document.addEventListener("visibilitychange", () => {
if (document.visibilityState == 'hidden' && platform.isRunning()) {
if (document.visibilityState == 'hidden' && platform && platform.isRunning()) {
_pause();
hidden = true;
} else if (document.visibilityState == 'visible' && hidden) {
@ -1973,11 +1973,14 @@ function addPageFocusHandlers() {
}
});
$(window).on("blur", () => {
if (platform.isRunning()) {
if (platform && platform.isRunning()) {
_pause();
hidden = true;
}
});
$(window).on("orientationchange", () => {
if (platform) setTimeout(platform.resize.bind(platform), 200);
});
}
// TODO: merge w/ embed.html somehow?

View File

@ -108,6 +108,7 @@ class VCSPlatform extends BasePlatform {
};
var jacanvas = $("#javatari-screen").find("canvas");
jacanvas.mousedown(rasterPosBreakFn);
this.resize();
}
loadROM(title, data) {
@ -389,6 +390,13 @@ class VCSPlatform extends BasePlatform {
connectProbe(probe:ProbeAll) {
this.probe = probe || this.nullProbe;
}
// resizing
resize() {
var scale = Math.min(1, ($('#emulator').width() - 24) / 640);
var xt = (1 - scale) * 50;
$('#javatari-div').css('transform', `translateX(-${xt}%) translateY(-${xt}%) scale(${scale})`);
}
};
// TODO: mixin for Base6502Platform?