11let snowflakesCount = 200 ; // Snowflake count, can be overwritten by attrs
2+ let minDuration = 10 ; // can be overwritten by attrs
3+ let maxDuration = 30 ; // can be overwritten by attrs
24let baseCSS = `` ;
35
46// set global attributes
57if ( typeof SNOWFLAKES_COUNT !== "undefined" ) {
68 snowflakesCount = SNOWFLAKES_COUNT ;
79}
10+ if ( typeof SNOWFLAKES_MIN_DURATION !== "undefined" ) {
11+ minDuration = SNOWFLAKES_MIN_DURATION ;
12+ }
13+ if ( typeof SNOWFLAKES_MAX_DURATION !== "undefined" ) {
14+ maxDuration = SNOWFLAKES_MAX_DURATION ;
15+ }
816if ( typeof BASE_CSS !== "undefined" ) {
917 baseCSS = BASE_CSS ;
1018}
@@ -21,6 +29,8 @@ function setHeightVariables() {
2129function getSnowAttributes ( ) {
2230 const snowWrapper = document . getElementById ( "snow" ) ;
2331 snowflakesCount = Number ( snowWrapper ?. dataset ?. count || snowflakesCount ) ;
32+ minDuration = Number ( snowWrapper ?. dataset ?. durmin || minDuration ) ;
33+ maxDuration = Number ( snowWrapper ?. dataset ?. durmax || maxDuration ) ;
2434}
2535
2636// This function allows you to turn on and off the snow
@@ -89,7 +99,10 @@ function generateSnowCSS(snowDensity = 200) {
8999 let randomYoyoTime = getRandomArbitrary ( 0.3 , 0.8 ) ;
90100 let randomYoyoY = randomYoyoTime * pageHeightVh ; // vh
91101 let randomScale = Math . random ( ) ;
92- let fallDuration = randomIntRange ( 10 , ( pageHeightVh / 10 ) * 3 ) ; // s
102+ let fallDuration = Math . min (
103+ randomIntRange ( minDuration , ( pageHeightVh / 10 ) * 3 ) ,
104+ maxDuration
105+ ) ; // s
93106 let fallDelay = randomInt ( ( pageHeightVh / 10 ) * 3 ) * - 1 ; // s
94107 let opacity = Math . random ( ) ;
95108
0 commit comments