loktar00/JQuery-Snowfall

"snow" falls to only 75% of the visible screen, not up to the bottom

Zurya opened this issue · 5 comments

I have implemented your snowfall plugin in few of our pages that have scroll bar. I implemented the plugin by using snowfall.js file and one line code below:

snowFall.snow(document.body, {round : true, minSize: 4, maxSize:7, flakeCount:50});

The issue is snow falls only up to 75% of the screen(not the page). But snow starts falling up to the bottom of the page once we change browser window size and if we restore it to original size, it keeps falling to the bottom.

If the page is refreshed, snow again falls only up to 75% of the screen.

Can you please suggest me a solution?

I may have fixed this in my multi-element support branch. I think this is caused by the offset calculations in the non jQuery version. In my branch, I modified the script to mimic the jQuery version more closely by inserting the flake images inside the target element rather than in the body using offsets to 'place' it over the target element.

This means that the flake positions only need to be positioned relative to the parent - so you don't need the top and bottom offsets - and removes some errors that can happen if those offsets are instantiated wrong.

Is it possible for you to provide me the modified script?

I also tried the jQuery version. Snow seems to fall up to bottom of the screen but again not to the bottom of the page! With non jQuery version, snow falls up to 75% of the screen.

Silarn/JQuery-Snowfall@51adb77

It should use the height of the target element to determine collision - so make sure your body is stretched all the way down the page. Might need a clearfix.

Hopefully this is addressed with the current version, and like @Silarn pointed out, make sure the elements boundaries actually extend to where you want the snow to fall.

Thank you @loktar00 and @Silarn for your prompt replies and suggestions.

I happened to figure out that position of the JS code matters through trial and errors. Initially, I was placing the JS code right after opening body tag. Today, I tried placing it to just before the closing body tag, snow started falling to the bottom!! :)

Thank you once again for your wonderful plugin! 👍

Cheers!!