Skip to content

Commit

Permalink
fix: fix canvas size
Browse files Browse the repository at this point in the history
  • Loading branch information
arianrhodsandlot committed Nov 7, 2023
1 parent 760e53a commit eb2d985
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nostalgist",
"description": "Nostalgist.js is a JavaScript library that allows you to run emulators of retro consoles within web browsers.",
"version": "0.5.0",
"version": "0.5.1",
"author": {
"name": "arianrhodsandlot",
"email": "[email protected]"
Expand Down
5 changes: 3 additions & 2 deletions src/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class Emulator {
private options: EmulatorOptions
private messageQueue: [Uint8Array, number][] = []
private gameStatus: GameStatus = 'initial'
private canvasInitialSize = { width: 0, height: 0 }

constructor(options: EmulatorOptions) {
this.options = options
Expand Down Expand Up @@ -63,6 +64,7 @@ export class Emulator {
if (!element.isConnected) {
document.body.append(element)
}
this.canvasInitialSize = this.getElementSize()

if (respondToGlobalEvents === false) {
if (!element.tabIndex || element.tabIndex === -1) {
Expand Down Expand Up @@ -334,8 +336,7 @@ export class Emulator {
}

private postRun() {
const size = this.getElementSize()
this.resize(size)
this.resize(this.canvasInitialSize)
this.fireGamepadEvents()
this.updateKeyboardEventHandlers()
}
Expand Down

0 comments on commit eb2d985

Please sign in to comment.