Skip to content

Commit 9f8ac19

Browse files
committed
mobile screens via css prop
1 parent f403b86 commit 9f8ac19

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

assets/style.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
:root {
3+
--heightScreen: 583px;
4+
--widthScreen: 800px;
35
--backgroundColor: white;
46
--buttonSize: 50px;
57
}
@@ -17,8 +19,10 @@ canvas {
1719
margin-left: auto;
1820
margin-right: auto;
1921
margin-top: 80px;
20-
width: 100% ;
21-
height: 100%;
22+
// width: 100%;
23+
// height: 100%;
24+
width: var(--widthScreen);
25+
height: var(--heightScreen);
2226
// background-image: url(http://github.com/"cassette-depth.svg");
2327
}
2428

src/sketch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ function setup() {
4848

4949
// define canvas dimensions for mobile screens
5050
if (window.innerWidth < widthScreen) {
51-
heightScreen = window.innerWidth * (heightScreen / widthScreen);
52-
widthScreen = window.innerWidth;
51+
root.style.setProperty('--heightScreen', window.innerWidth * (heightScreen / widthScreen) + "px");
52+
root.style.setProperty('--widthScreen', window.innerWidth + "px");
5353
}
5454

5555
canvas = createCanvas(widthScreen, heightScreen);

0 commit comments

Comments
 (0)