Skip to content

use viewport units to prevent canvas from overflowing#4

Open
Klangspiel wants to merge 1 commit intoheadjump:masterfrom
Klangspiel:master
Open

use viewport units to prevent canvas from overflowing#4
Klangspiel wants to merge 1 commit intoheadjump:masterfrom
Klangspiel:master

Conversation

@Klangspiel
Copy link

this PR keeps the canvas from overflowing the screen in landscape mode.
I've kept the original widths to fall back to for browsers without viewport unit support.

max-width: 512px; /* max game size: 512px */
width: 512px; height: 512px;
width: 100vmin; /* ensures the game won't overflow the screen */
image-rendering: optimizeSpeed;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Idea to use vmin there.

I'll test this soon, but at I first look I wonder if it shouldn't be more like

width: 512px;
height: 512px;
max-width: 100vmin;
max-height: 100vmin;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went for the max-width in px and width in vmin in order to keep the change as small as possible. In practice, both are interchangeable without any change in behavior – the canvas will still cap out at either 512px or 100vmin. Your suggestion feels a lot clearer, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants