npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@autots/redpacket

v2.1.2

Published

A redpacket rain component based on typescript and vanilla js

Downloads

5

Readme

redpacket-rain

A redpacket rain component based on typescript and vanilla js.

Installing

Using npm:

$ npm install @autots/redpacket -S

Note: cdn is not supported at now, maybe you can deliver the file dist/redpacket.min.js to your own cdn server.

Example

1. Used in modular manner

import RedPacket from '@autots/redpacket';

const redPacket = new RedPacket({
  imgUrl: '//s.autoimg.cn/www/site/livechannel/images/',
  container: 'test',
  countdownTime: 3,
  remainTime: 30,
  rainType: [
    { score: 1, speed: 1, ratio: 7 },
    { score: 2, speed: 1, ratio: 2 },
    { score: 10, speed: 1, useless: 70, ratio: 1 }
  ],
  angle: 0.01,
  onDuration(time, count) {
    console.log(time, count);
  },
  onStart() {
    console.log('game start');
  },
  onEnded(count) {
    console.log(`game over! your score: ${count}`);
  }
})

Used in browser plugin

<script src="dist/redpacket.min.js"></script>

<script>
  const redPacket = new AutoTs.RedPacket(...); // same above
</script>

There is a global variable AutoTs, and RedPacket property is the constructor.

API

const redPacket = new RedPacket(config);

| Name | Type | Default | Optional | Description | |:----------:|:-----------------------------:|:-----------:|:----:|:--------------------------| | imgUrl | string | -- | NO | base URL of images | | container | string | -- | NO | id of the canvas element | | angle | number | 0.3 | YES | drop angle | | boundary | number | 0 | YES | distance from left&right | | countdownTime | number | 0 | YES | count down from ( <= 5 ) | | remainTime | number | 30 | YES | game duration time | | rainType | ({ score: number, speed: number, useless?: number, ratio: number })[] | -- | NO | type of rain 1. if pic has useless content which like glowing shadow, make sure four sides distance equal 2. ratio sum of all type must equal 10 | | onDuration | Function | -- | YES | callback during game remaining countdown ( time, count ) | | onStart | Function | -- | YES | callback when game start | | onEnded | Function | -- | YES | callback when game over ( score ) |

you can stop during the game by using:

redPacket.close();

Rules

config.imgUrl is the base url of images. the names of images can not be changed, there are images you should prepare:

  • raindrop${index + 1}.png ( for (let index in config.rainType) )
  • bingo.png ( click effect like firework )
  • meteor.png ( decoration like meteor )
  • countdown-bg.png
  • countdown.png ( vertical sprite of 5 4 3 2 1 go )
  • count-bg.png