0.8.2 • Published 5 months ago

react-native-fast-confetti v0.8.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

react-native-fast-confetti šŸŽŠ

šŸŽļø The fastest confetti animation library in react native written using Skia Atlas API

https://github.com/user-attachments/assets/968a376f-f20c-4a94-886b-65b1625891ae

Installation

!IMPORTANT This library depends on react-native-reanimated and @shopify/react-native-skia. Make sure to install those first.

yarn add react-native-fast-confetti

Usage

<Confetti />

This animation creates a basic confetti effect where pieces fall from the top in a straight line.

https://github.com/user-attachments/assets/d89ef248-6b27-435e-a322-fb62a3550343

You can also use the cannonPositions option to simulate confetti being launched from cannons before falling. in the screen recording, there's only one cannon. You can also pass multiple cannon positions to shoot confetti from multiple cannons

https://github.com/user-attachments/assets/f59b930d-7c22-4901-9c3e-995cc66b6ae9

import { Confetti } from 'react-native-fast-confetti';

// ...

return (
    <View>
    {...Your other components}
    <Confetti />
    {...Your other components}
    </View>
)

<PIConfetti />

This confetti type creates an effect where flakes burst outward from the center, and then drift down gracefully.

https://github.com/user-attachments/assets/30008c3b-0f1a-4dff-afdb-2ded80809291

import { PIConfetti } from 'react-native-fast-confetti';

// ...

return (
    <View>
    {...Your other components}
    <PIConfetti />
    {...Your other components}
    </View>
)

<Confetti /> Props

NameRequiredDefault ValueDescription
countNo200Number of confetti pieces to render.
flakeSizeNo{ width: 8, height: 16 }The size of each confetti flake (object with width and height).
widthNoSCREEN_WIDTHThe width of the confetti's container.
heightNoSCREEN_HEIGHTThe height of the confetti's container.
fallDurationNo8000 msThe duration of confetti falling down (milliseconds).
blastDurationNo300 msThe duration of confetti blast (milliseconds). Use with cannonsPositions
cannonsPositionsNoN/AAn array of positions from which confetti flakes should blast.
autoplayNotrueWhether the animation should play on mount.
isInfiniteNofollows autoplayWether the animation should play again after it ends.
colorsNoN/AThe array of confetti flakes colors.
autoStartDelayNo0Delay before the confetti animation starts automatically (in ms).
verticalSpacingNo30The approximate space between confetti flakes vertically. Lower value results in denser confetti.
fadeOutOnEndNoN/AShould the confetti flakes fade out as they reach the bottom.
onAnimationStartNoN/ACallback function triggered when the falling animation starts.
onAnimationEndNoN/ACallback function triggered when the falling animation ends.
sizeVariationNo0A value of 0.1 means flakes can vary up to 10% smaller than the base (flakeSize), with more flakes clustering towards the original size and fewer towards the minimum size. Recommended value is between 0 and 0.5
radiusRangeNo0, 0The range of the radius of the confetti flakes. A tuple of min, max values from which a random radius will be selected for each flake.

<PIConfetti /> Props

NameRequiredDefault ValueDescription
countNo200Number of confetti pieces to render.
flakeSizeNo{ width: 8, height: 16 }The size of each confetti flake (object with width and height).
widthNoSCREEN_WIDTHThe width of the confetti's container.
heightNoSCREEN_HEIGHTThe height of the confetti's container.
blastDurationNo300 msThe duration of confetti blast (milliseconds).
fallDurationNo8000 msThe duration of the confetti animation in milliseconds.
blastPositionNo{ x: containerWidth / 2, y: 150 }The position from which confetti flakes should blast.
blastRadiusNo180The radius of the blast.
colorsNoN/AThe array of confetti flakes colors.
fadeOutOnEndNoN/AShould the confetti flakes fade out as they reach the bottom.
onAnimationStartNoN/ACallback function triggered when the falling animation starts.
onAnimationEndNoN/ACallback function triggered when the falling animation ends.
sizeVariationNo0A value of 0.1 means flakes can vary up to 10% smaller than the base (flakeSize), with more flakes clustering towards the original size and fewer towards the minimum size. Recommended value is between 0 and 0.5
radiusRangeNo0, 0The range of the radius of the confetti flakes. A tuple of min, max values from which a random radius will be selected for each flake.

Methods

NameDescription
restartStart the animation from the beginning.
pausePause the animation.
resetReset the animation and prevent it from playing.
resumeResume the animation from where it paused.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

0.8.1

5 months ago

0.8.0

5 months ago

0.8.2

5 months ago

0.7.0

6 months ago

0.6.1

8 months ago

0.5.2

8 months ago

0.6.0

8 months ago

0.5.1

8 months ago

0.5.0

8 months ago

0.4.0

8 months ago

0.3.0

8 months ago

0.2.6

8 months ago

0.2.5

8 months ago

0.2.4

8 months ago

0.2.3

8 months ago

0.2.2

8 months ago

0.2.1

8 months ago

0.2.0

8 months ago