Skip to content

Commit 96fb828

Browse files
author
Meredith G Hoo
committed
fixed mobile flower size for more phones
1 parent d92a3ba commit 96fb828

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

js/secrets.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,26 @@ function setup() {
1212
var width = $('body').width();
1313
var size = 150;
1414
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;
1815

1916
var isMobile = window.matchMedia("only screen and (max-width: 450px)").matches ||
2017
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
2118
var isOtherMediaQuery = window.matchMedia("only screen and (min-width:1080px)").matches;
2219
if(isMobile && !isOtherMediaQuery) {
23-
size = 300;
24-
padding = 80;
25-
radius = Math.floor(height / rows - 3);
20+
size = 250;
21+
padding = 250;
2622
}
23+
var rows = Math.floor(height / size);
24+
var cols = Math.floor(width / size);
25+
var radius = Math.floor(Math.max(width, height) / Math.max(rows - 1, cols - 1)) / 2;
2726

28-
console.log(width);
29-
console.log(isMobile);
30-
console.log(rows);
31-
console.log(cols);
32-
console.log(radius);
33-
27+
if(isMobile && !isOtherMediaQuery) {
28+
radius = Math.floor(height / (rows + 2));
29+
}
30+
3431
makeGrid(rows, cols);
3532
shapes = makeFlowers(radius);
3633
addSvgsToCells(size, padding);
37-
offsetEvenRows(size);
34+
offsetEvenRows(size + padding);
3835
}
3936

4037
function addSvgsToCells(size, padding) {
@@ -54,7 +51,7 @@ function offsetEvenRows(size) {
5451
$(".row").each(function (index, object) {
5552
if (index % 2) {
5653
$(object).css("position", "relative");
57-
$(object).css("left", size / 2 * - 1 + "px");
54+
$(object).css("left", size / 2 * -1 + "px");
5855
}
5956
});
6057
}

0 commit comments

Comments
 (0)