Skip to content

Commit 3d837d7

Browse files
committed
renamed size variables and function variables
1 parent 856e870 commit 3d837d7

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

js/secrets.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,38 @@ $(function() {
1010
function setup() {
1111
var height = $('body').height();
1212
var width = $('body').width();
13-
var size = 150;
14-
var padding = 50;
13+
var svgSize = 150;
14+
var padding = 20;
1515

16-
var isMobile = window.matchMedia("only screen and (max-width: 450px)").matches ||
16+
var isMobile = window.matchMedia("only screen and (max-width: 850px)").matches ||
1717
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
1818
var isOtherMediaQuery = window.matchMedia("only screen and (min-width:1080px)").matches;
1919
if(isMobile && !isOtherMediaQuery) {
20-
size = 250;
21-
padding = 250;
20+
svgSize = 250;
21+
padding = 40;
2222
}
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;
2623

2724
if(isMobile && !isOtherMediaQuery) {
2825
radius = Math.floor(height / (rows + 2));
2926
}
3027

3128
makeGrid(rows, cols);
29+
var rows = Math.floor(height / svgSize);
30+
var cols = Math.floor(width / svgSize);
31+
var radius = Math.floor(Math.max(width, height) / Math.max(rows, cols)) / 2;
32+
3233
shapes = makeFlowers(radius);
33-
addSvgsToCells(size, padding);
34-
offsetEvenRows(size + padding);
34+
addSvgs(svgSize + padding, rows, cols);
35+
var divSize = $("#cell0").outerWidth();
36+
positionCells(cols, divSize);
3537
}
3638

37-
function addSvgsToCells(size, padding) {
38-
$(".cell").each(function (index, object) {
39+
function addSvgs(size, rows, cols) {
40+
$(".cell").each(function (i, o) {
3941
var two = new Two({
40-
width: size + padding,
41-
height:size + padding
42-
}).appendTo(object);
42+
width: size,
43+
height: size
44+
}).appendTo(o);
4345
var shape = pickFlower(shapes);
4446
shape.translation.set(two.width / 2, two.height / 2);
4547
two.add(shape);

0 commit comments

Comments
 (0)