effect-snow
Global import
<script src="dist/snow.min.js"></script>
ESM import
import Snow from 'effect-snow';
Usage
<body>
<button id="start">start</button>
<button id="stop">stop</button>
</body>
let it = new Snow(document.querySelector('body'));
document.getElementById('start').addEventListener('click', () => it.start());
document.getElementById('stop').addEventListener('click', () => it.stop());
API Reference
Constructor
const snow = new Snow(node, options);
name | description |
---|
node <Node> | element to apply the effect to |
options <object> | see additional options |
Methods
snow.start();
snow.stop();
name | description |
---|
start() | Start the snow if it is not started yet. This will clear any existing snow immediately. |
stop() | Stop the snow. This will still allow the remaining snow to finish the animation. |
Additional options
name | range | default |
---|
indentisity <number> | [1, 5] | 3 |
span <number> | - | 375 |
let it = new Snow(element, { intensity: 5, span: 400 });
Credits
The physics of the snow fall is adapted from Aatish Bhatia's Snow Globe Experiment.