Skip to content

Commit be370c4

Browse files
committed
fixed padding issue
1 parent 228e31f commit be370c4

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

js/2secrets.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,31 @@ $(function() {
1010
function setup() {
1111
var height = $('body').height();
1212
var width = $('body').width();
13+
var size = 150;
14+
var padding = 20;
15+
16+
var isMobile = window.matchMedia("only screen and (max-width: 850px)").matches ||
17+
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
18+
var isOtherMediaQuery = window.matchMedia("only screen and (min-width:1080px)").matches;
19+
if(isMobile && !isOtherMediaQuery) {
20+
size = 250;
21+
padding = 40;
22+
}
1323

14-
var size = getShapeSize();
1524
var rows = Math.floor(height / size);
1625
var cols = Math.floor(width / size);
1726
var radius = Math.floor(Math.max(width, height) / Math.max(rows, cols)) / 2;
1827

1928
makeGrid(rows, cols);
2029
shapes = makeFlowers(radius);
21-
addSvgsToCells(size);
22-
}
23-
24-
function getShapeSize() {
25-
var size;
26-
var isMobile = window.matchMedia("only screen and (max-width: 850px)").matches ||
27-
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
28-
var isOtherMediaQuery = window.matchMedia("only screen and (min-width:1080px)").matches;
29-
if(isMobile && !isOtherMediaQuery) {
30-
size = 200;
31-
} else {
32-
size = 150;
33-
}
34-
return size;
30+
addSvgsToCells(size, padding);
3531
}
3632

37-
function addSvgsToCells(size) {
33+
function addSvgsToCells(size, padding) {
3834
$(".cell").each(function (index, object) {
3935
var two = new Two({
40-
width: size + 20,
41-
height:size + 20
36+
width: size + padding,
37+
height:size + padding
4238
}).appendTo(object);
4339
var shape = pickFlower(shapes);
4440
shape.translation.set(two.width / 2, two.height / 2);

0 commit comments

Comments
 (0)