File tree Expand file tree Collapse file tree 2 files changed +13
-19
lines changed
Expand file tree Collapse file tree 2 files changed +13
-19
lines changed Original file line number Diff line number Diff line change 88.row {
99 display : flex;
1010}
11- .row : nth-child (2n) {
12- position : relative;
13- left : -75px ;
14- }
15-
1611svg {
1712 margin : 8px ;
1813}
1914
2015.cell : hover , .cell : visited , .cell : focus {
21- animation : loaderAnim 5s ease-in-out infinite normal forwards;
16+ animation : rotate 5s ease-in-out infinite normal forwards;
2217 padding : 0 ;
2318 margin : 0 ;
2419}
2520
2621
27- @keyframes loaderAnim {
22+ @keyframes rotate {
2823 0% {
2924 transform : rotate (0deg );
3025 }
3530 transform : rotate (0deg );
3631 }
3732}
38- @media only screen and (max-width : 450px ) {
39- .row : nth-child (2n) {
40- position : relative;
41- left : 75px ;
42- }
43- body {
44- left : -100px ;
45- top : 10px ;
46- }
47- }
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ function setup() {
2828 makeGrid ( rows , cols ) ;
2929 shapes = makeFlowers ( radius ) ;
3030 addSvgsToCells ( size , padding ) ;
31+ offsetEvenRows ( size ) ;
3132}
3233
3334function addSvgsToCells ( size , padding ) {
@@ -43,13 +44,21 @@ function addSvgsToCells(size, padding) {
4344 } ) ;
4445}
4546
47+ function offsetEvenRows ( size ) {
48+ $ ( ".row" ) . each ( function ( index , object ) {
49+ if ( index % 2 ) {
50+ $ ( object ) . css ( "position" , "relative" ) ;
51+ $ ( object ) . css ( "left" , size / 2 * - 1 + "px" ) ;
52+ }
53+ } ) ;
54+ }
55+
4656function makeGrid ( rows , cols ) {
4757 $ ( 'body' ) . empty ( ) ;
4858 for ( var r = 0 ; r < rows ; r ++ ) {
4959 var rowId = "row" + r ;
5060 var row = $ ( "<div/>" ) . addClass ( "row" ) . attr ( "id" , rowId ) . appendTo ( 'body' ) ;
51- var vi = r / ( rows - 1 ) ;
52- for ( var c = 0 ; c < cols ; c ++ ) {
61+ for ( var c = 0 ; c < cols + 1 ; c ++ ) {
5362 var cellId = "cell" + ( ( r * rows ) + c ) ;
5463 $ ( row ) . append ( '<div class="cell" id="' + cellId + '"></div>' ) ;
5564 }
You can’t perform that action at this time.
0 commit comments