loktar00 / JQuery-Snowfall

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

Window resize results in 0 height #14

Closed simonajones closed 9 years ago

simonajones commented 10 years ago

Hi, I'm using the Jenkins wall display plugin which has a 'christmas' theme that displays snowflakes using JQuery-Snowfall. Everything works fine until the window is resized.

The size calculation sets the height to 0, which stops the snowflakes from being painted as expected. The log in the console says "0".

It looks like the binding to the $(window) does give the wrong value when the plugin is initialised with the $(document).snowfall({..})

$(window).bind("resize", function(){
elHeight = $(element)[0].clientHeight; elWidth = $(element)[0].offsetWidth; console.log(elHeight); });

Is this something you have seen before? Thanks for the plugin, Simon

Flip120 commented 10 years ago

I have the same problem and fixed it by restarting the snow: $(window).bind("resize", function(){ $(document).snowfall('clear'); $(document).snowfall({...}); });

loktar00 commented 9 years ago

Looked into this bug a bit tonight, I don't think the snowfall script is doing it since I listen to window resize events. Went crazy resizing the window tonight and couldn't reproduce.