Socket
Book a DemoInstallSign in
Socket

react-native-confetti-cannon

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-confetti-cannon

React Native confetti explosion and fall like iOS does.

1.5.2
latest
npmnpm
Version published
Weekly downloads
58K
2.19%
Maintainers
1
Weekly downloads
 
Created
Source

React-native-confetti-cannon

CircleCI NPM PLATFORMS GITHUB

Live demo

:rocket: Try yourself on Storybook web version

Installation

npm install react-native-confetti-cannon
# or
yarn add react-native-confetti-cannon

Usage

import ConfettiCannon from 'react-native-confetti-cannon';

const MyComponent = () => (
  <ConfettiCannon count={200} origin={{x: -10, y: 0}} />
);

Props

NameTypeDescriptionRequiredDefault
countnumberitems count to displayrequired
origin{x: number, y: number}animation position originrequired
explosionSpeednumberexplosion duration (ms) from origin to top350
fallSpeednumberfall duration (ms) from top to bottom3000
fadeOutbooleanmake the confettis disappear at the endfalse
colorsstring[]give your own colors to the confettisdefault colors
autoStartbooleanauto start the animationtrue
autoStartDelaynumberdelay to wait before triggering animation0

Events

NameReturnsDescriptionRequired
onAnimationStartvoidcallback triggered at animation start
onAnimationResumevoidcallback triggered at animation resume
onAnimationStopvoidcallback triggered at animation stop
onAnimationEndvoidcallback triggered at animation end

Methods

NameReturnsDescriptionRequired
startvoidstart the animation programmatically
resumevoidresume the animation programmatically
stopvoidstop the animation programmatically

For example:

import ConfettiCannon from 'react-native-confetti-cannon';

class MyComponent extends React.PureComponent {
  explosion;

  handleSomeKindOfEvent = () => {
    this.explosion && this.explosion.start();
  };

  render() {
    return (
      <ConfettiCannon
        count={200}
        origin={{x: -10, y: 0}}
        autoStart={false}
        ref={ref => (this.explosion = ref)}
      />
    );
  }
}

Examples

Deep into the example folder to see the stories and run:

npm install && npm start

And choose one of the following Expo commands:

  • i: open in iOS simulator
  • a: open in Android emulator
  • w: open in web browser

:warning: Warning

It is strongly recommended to use 1.2.0 or higher to avoid this warning introduced in React-Native 0.62:

Animated: useNativeDriver was not specified. This is a required option and must be explicitly set to true or false

Keywords

react

FAQs

Package last updated on 03 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.