11function generateVines ( ) {
2- const vinesContainer = document . getElementById ( 'vines' ) ;
3- vinesContainer . innerHTML = "" ;
2+ const vinesContainer = document . getElementById ( 'vines' ) ;
3+ vinesContainer . innerHTML = "" ;
44
5- const vineWidth = 32 ;
6- const gap = 64 ;
7- const spacing = vineWidth + gap ;
8- const maxHeight = 2 ;
9- const minLeft = 360 ;
5+ const vineWidth = 32 ;
6+ const gap = 64 ;
7+ const spacing = vineWidth + gap ;
8+ const maxHeight = 2 ;
9+ const minLeft = 360 ;
1010
11- const header = document . querySelector ( '.header' ) ;
12- const headerWidth = header . offsetWidth ;
13- vinesContainer . style . width = headerWidth + 'px' ;
11+ const header = document . querySelector ( '.header' ) ;
12+ const headerWidth = header . offsetWidth ;
13+ vinesContainer . style . width = headerWidth + 'px' ;
1414
15- const availableWidth = headerWidth - minLeft ;
16- const totalColumns = Math . floor ( availableWidth / spacing ) ;
15+ const availableWidth = headerWidth - minLeft ;
16+ const totalColumns = Math . floor ( availableWidth / spacing ) ;
1717
18- for ( let i = 0 ; i < totalColumns ; i ++ ) {
19- if ( i % 4 === 0 ) continue ;
20- const vineHeight = Math . floor ( Math . random ( ) * maxHeight ) + 1 ;
21- const left = minLeft + i * spacing ;
18+ for ( let i = 0 ; i < totalColumns ; i ++ ) {
19+ if ( i % 4 === 0 ) continue ;
20+ const vineHeight = Math . floor ( Math . random ( ) * maxHeight ) + 1 ;
21+ const left = minLeft + i * spacing ;
2222
23- for ( let j = 0 ; j < vineHeight ; j ++ ) {
24- const vine = document . createElement ( 'img' ) ;
25- vine . src = 'img/bg/vine.png' ;
26- vine . style . width = vineWidth + 'px' ;
27- vine . style . position = 'absolute' ;
28- vine . style . left = `${ left } px` ;
29- vine . style . top = `${ j * vineWidth } px` ;
30- vine . style . display = 'block' ;
31- vinesContainer . appendChild ( vine ) ;
32- }
23+ for ( let j = 0 ; j < vineHeight ; j ++ ) {
24+ const vine = document . createElement ( 'img' ) ;
25+ vine . src = 'img/bg/vine.png' ;
26+ vine . style . width = vineWidth + 'px' ;
27+ vine . style . position = 'absolute' ;
28+ vine . style . left = `${ left } px` ;
29+ vine . style . top = `${ j * vineWidth } px` ;
30+ vine . style . display = 'block' ;
31+ vinesContainer . appendChild ( vine ) ;
3332 }
3433 }
34+ }
3535
36- window . addEventListener ( 'DOMContentLoaded' , generateVines ) ;
36+ window . addEventListener ( 'DOMContentLoaded' , generateVines ) ;
3737
38- let resizeTimeout ;
39- window . addEventListener ( 'resize' , ( ) => {
40- clearTimeout ( resizeTimeout ) ;
41- resizeTimeout = setTimeout ( ( ) => {
42- location . reload ( ) ;
43- } , 250 ) ;
44- } ) ;
38+ let resizeTimeout ;
39+ window . addEventListener ( 'resize' , ( ) => {
40+ clearTimeout ( resizeTimeout ) ;
41+ resizeTimeout = setTimeout ( ( ) => {
42+ generateVines ( ) ;
43+ } , 250 ) ;
44+ } ) ;
0 commit comments