Comments (5)
For what I need I have figured a dirty fix for the time being.. as I want .snowfall() to be on different div's which aren't on the screen at the same time this bit of code works for me
// Snow Fall
var outside = jQuery('.scene3 .outside');
jQuery(function () {
outside.data('switch', 'on');
});
jQuery(window).scroll(function () {
if (jQuery(document).scrollTop() > 12500) {
if (jQuery(outside).data('switch') == 'on') {
jQuery(outside).data('switch', 'off');
//Clear Scene1
jQuery('.scene1').snowfall('clear');
//Start Scene3
jQuery(outside).snowfall({
image :'/wp-content/themes/christmas/images/snow.png',
flakeIndex: 28,
minSize: 11,
flakeCount: 10,
maxSize:15
});
}
} else {
if (jQuery(outside).data('switch') == 'off') {
jQuery(outside).data('switch', 'on');
//Clear Scene3
jQuery(outside).snowfall('clear');
//Start Scene1
jQuery('.scene1').snowfall({
image :'/wp-content/themes/christmas/images/snow.png',
flakeIndex: 28,
minSize: 11,
maxSize:15
});
}
}
});
from jquery-snowfall.
I recently made a pull request to address this problem.
It does so by moving the flakes array to a global scope (within the plugin). Then, during creation and garbage collection, I carefully remove and fill in the associated flake ids from the global flakes array sorted by the id number.
This allows every snowflake to have a unique id so that the animation code works correctly and should also fill in old ids of erased flakes rather than continuing to create bigger and bigger id numbers.
from jquery-snowfall.
The pull request is #28 but I have not yet ported the jQuery code to the 'stock javascript' version.
from jquery-snowfall.
Both versions of the script should now work with multiple elements with my changes, see #28
from jquery-snowfall.
👍 thanks to the hard work by @Silarn this should be resolved and has been merged in.
from jquery-snowfall.
Related Issues (20)
- Snow Globe Effect HOT 1
- Cannot read property 'x' of undefined HOT 1
- Feature request: rotation of images as they fall HOT 2
- cdnjs HOT 3
- Bower config - 'main' property
- Position error HOT 2
- Stop after n seconds? HOT 3
- Does it work with jquery version 1? HOT 2
- Jquery, Bootstrap, custom jscripts = not working?
- Change Positioning from top/left to transform HOT 2
- Collect doesn't seem to be working HOT 3
- Possible to have the snowflakes go UP (backwards) or a certain direction?
- Missing jQuery in Example Index HOT 2
- AJAX content
- Scrollbar flashing referred to in Issue #21 appears to still exist.
- Option to exclude mobile devices HOT 3
- Really high CPU load with just a few flakes
- Only show image base snowflakes after the image has fully loaded HOT 1
- Without jQuery Version HOT 2
- Can I use snowfall.js for commercial purposes?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-snowfall.