Skip to content

Commit 420055c

Browse files
author
Meredith G Hoo
committed
mobile fix
1 parent 60146f4 commit 420055c

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

js/2secrets.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@ function setup() {
1111
var height = $('body').height();
1212
var width = $('body').width();
1313
var size = 150;
14-
var padding = 20;
14+
var padding = 50;
15+
var rows = Math.floor(height / size);
16+
var cols = Math.floor(width / size);
17+
var radius = Math.floor(Math.max(width, height) / Math.max(rows - 1, cols - 1)) / 2;
1518

16-
var isMobile = window.matchMedia("only screen and (max-width: 850px)").matches ||
19+
var isMobile = window.matchMedia("only screen and (max-width: 450px)").matches ||
1720
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
1821
var isOtherMediaQuery = window.matchMedia("only screen and (min-width:1080px)").matches;
1922
if(isMobile && !isOtherMediaQuery) {
20-
size = 250;
21-
padding = 40;
23+
size = 300;
24+
padding = 80;
25+
radius = Math.floor(height / rows) / 2;
2226
}
2327

24-
var rows = Math.floor(height / size);
25-
var cols = Math.floor(width / size);
26-
var radius = Math.floor(Math.max(width, height) / Math.max(rows, cols)) / 2;
28+
console.log(width);
29+
console.log(isMobile);
30+
console.log(rows);
31+
console.log(cols);
32+
console.log(radius);
2733

2834
makeGrid(rows, cols);
2935
shapes = makeFlowers(radius);

0 commit comments

Comments
 (0)