mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-22 14:33:51 +00:00
vcs: resize screen
This commit is contained in:
parent
3041b08ae0
commit
bf6e399ce9
@ -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?
|
||||
|
@ -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?
|
||||
|
Loading…
Reference in New Issue
Block a user