loktar00 / JQuery-Snowfall

Makes it snow on any web page or specific element.
http://loktar00.github.io/JQuery-Snowfall/
712 stars 221 forks source link

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

Closed Zurya closed 9 years ago

Zurya commented 9 years ago

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?

Silarn commented 9 years ago

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.

Zurya commented 9 years ago

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 commented 9 years ago

Silarn/JQuery-Snowfall@51adb771d313e1d14beddb75a5ef7fe5755396f4

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.

loktar00 commented 9 years ago

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.

Zurya commented 9 years ago

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! :+1:

Cheers!!