Skip to content

Commit b9a39ce

Browse files
committed
added mobile sizing
1 parent 187c882 commit b9a39ce

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

js/secrets.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,20 @@ var two = new Two({
55
}).appendTo(document.body);
66
document.body.style.background = 'black';
77

8-
var rows = Math.floor(two.height / 150);
9-
var cols = Math.floor(two.width / 150);
10-
var radius = Math.floor(Math.max(two.width, two.height) / Math.max(rows, cols)) / 2;
8+
9+
var radius = 0, rows = 0, cols = 0;
10+
var isMobile = window.matchMedia("only screen and (max-width: 850px)").matches ||
11+
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
12+
var isOtherMediaQuery = window.matchMedia("only screen and (min-width:1080px)").matches;
13+
if(isMobile && !isOtherMediaQuery) {
14+
rows = Math.floor(two.height / 200);
15+
cols = Math.floor(two.width / 200);
16+
radius = Math.floor(two.height / rows) * .62;
17+
} else {
18+
rows = Math.floor(two.height / 150);
19+
cols = Math.floor(two.width / 150);
20+
radius = Math.floor(Math.max(two.width, two.height) / Math.max(rows, cols)) / 2;
21+
}
1122
var shapes = makeFlowers();
1223
var container = two.makeGroup();
1324

0 commit comments

Comments
 (0)