1.0.8 • Published 3 years ago

effect-snow v1.0.8

Weekly downloads
12
License
MIT
Repository
github
Last release
3 years ago

effect-snow

CodePen Demo

Snow falling

Global import

From package

npm install effect-snow
<script src="node_modules/effect-snow/dist/snow.min.js"></script>

or from CDN

<script src="https://unpkg.com/effect-snow"></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);
namedescription
node <Node>element to apply the effect to
options <object>see additional options

Methods

snow.start();
snow.stop();
namedescription
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

namerangedefault
indentisity <number>[1, 5]3
span <number>-375
// create a snow scene that has the highest intensity and each
// snow spiral width is 400px.
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.

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago