Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

let-it-go

EastSun55662.2kMIT1.1.0TypeScript support: included

❄️ Let your website snow instantly

let-it-go, snow, snowfall, canvas

readme

let-it-go logo

❄️ Let It Go

NPM Version NPM Downloads License

Buy Me A Coffee

Let your website snow instantly, zero dependencies, small & fast

🔗 https://eastsun5566.github.io/let-it-go/

✨ Installation

npm i let-it-go

🚀 Usage

Basic

import { LetItGo } from "let-it-go";

// just snow!
const snow = new LetItGo();

Advance

Options

// create snow with some options
const snow = new LetItGo({
  // root container, defaults to `document.body`
  root: document.getElementById("root"),
  // number of snowflake, defaults to `window.innerWidth`
  number: 1000,
  // velocity x range of snowflake, defaults to `[-3, 3]`
  velocityXRange: [-3, 3],
  // velocity y range of snowflake, defaults to `[1, 5]`
  velocityYRange: [1, 5],
  // radius range of snowflake, defaults to `[0.5, 1]`
  radiusRange: [0.5, 1],
  // color of snowflake color, defaults to `#ffffff`
  color: "#ffffff",
  // opacity range of snowflake, defaults to `[0.8, 1]`
  alphaRange: [0.8, 1],
  // background color of `canvas` element, defaults to `transparent`
  backgroundColor: "transparent",
  // style prop of `canvas` element, defaults to `{ zIndex: -1, pointerEvents: 'none' }`
  style: { zIndex: -999, pointerEvents: "none" },
});

// you can use static prop `DEFAULT_OPTIONS` to get all the default options
const allTheDefaultOptions = LetItGo.DEFAULT_OPTIONS;

Dynamic get/set instance options

/** the number of snowflake */
const snowflakeNumber = snow.number;

// you can directly update instance prop and it will reflect those change limitedly
snow.number = 5566;
snow.color: "#333333"
snow.velocityXRange = [-10, 50]; // must be tuple `[number, number]`

Some other methods

// just stop animation
snow.letItStop();

// and snow again!
snow.letItGoAgain();

// stop animation & remove mounted `canvas` element
snow.clear();

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.1.0 (2024-11-15)

Features

Bug Fixes

  • add assertions and improve error handling in core functionality (5c6ac51)
  • enhance clean up (902aba2)
  • fix build & add ci build task (e869da4)
  • remove unnecessary condiction (536c09f)

1.0.0 (2023-08-05)

0.0.10 (2023-08-05)

Features

Bug Fixes

  • use style prop instead of setProperty (36c09f8)

0.0.9 (2022-12-29)

0.0.8 (2022-12-29)

Features

Bug Fixes

  • should can be installed by any pakage manager (68d2bcf)
  • typing (e81a68b)

0.0.7 (2022-12-24)

Features

Bug Fixes