0.0.3 • Published 11 months ago

@soluelue/react-native-fireworks v0.0.3

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

react-native-SLLFireworks

license badge react-native badge react-native-reanimated

A React Native project that can be used to highlight something important or to express fireworks.

Prerequisites


react nataive reanimated install guide

npm i react-native-reanimated

Props.


Attribute NametypeDescriptionDefaultOption
refuseRef()fireworksRef is a variable representing the reference of the SLLFireworks component. It allows accessing the methods or properties of the component.useRef()X
positionXnumberIt represents the X-coordinate position of the SLLFireworks component.randomO
positionYnumberIt represents the Y-coordinate position of the SLLFireworks component.randomO
particleSizenumberIt specifies the size of each firework or particle in pixels.Image size or 30O
radiusnumberIt represents the maximum radius within which the firework or particle can move. The value is specified in pixels.200O
innerRadiusnumberIt represents the inner radius of the firework or particle. It determines the shape of the firework. The value is specified in pixels.0O
radiusNoisenumberIt indicates the amount of noise added to the particle's radius. A larger value will make the particle move in a more irregular path. The value is specified in pixels.0O
zIndexnumberIt represents the stacking order of the component. A higher value means it will be displayed on top.defaultO
iterationnumberIt denotes the number of times the firework animation will repeat. If set to 1, the animation will run once.1O
numberOfParticlenumberIt represents the number of particles generated.20O
particleSourcesArray(local image, uri image)It is an array of image sources used for the firework or particle.Circle particle viewO
autoStartbooleanIt indicates whether the component will automatically start the animation. If set to true, the animation will start automatically when the component is rendered.falseO
animationDurationnumber(miliseconds)It specifies the duration of the firework animation in milliseconds.500O
onAnimationDonefuncrionIt is a callback function that is called when the animation is completed. The onAnimationDone function can be used to perform any desired action when the animation is done.undefinedO
angleTypestring (equal, random)It determines the movement angle of the particle. When set to 'equal', particles move at the same angle.'random'O
particleColorsArrayIt is an array of color values that can be assigned to each particle. Each particle can have a different color.'black' or nullO

Ref Handler


FunctionDescription
startInitiates the fireworks animation.
stopHalts the fireworks animation.

Ref function Example


<View>
      {/* start button */}
      <TouchableOpacity style={styles.simpleButton}
                        onPress={()=>{
                          if(fireworksRef.current != null){
                                // Start the fireworks animation.
                                fireworksRef.current.start();
                            }
                        }
                        }>
        <Text>start</Text>
      </TouchableOpacity>
      {/* stop button */}
      <TouchableOpacity style={styles.simpleButton} 
                      onPress={()=>{
                        if(fireworksRef.current != null){
                            // Stop the fireworks animation.
                            fireworksRef.current.stop();
                          }
                      }
                     }>
        <Text>stop</Text>
      </TouchableOpacity>
    </View>

Example


Circle Type

<SLLFireworks
        ref={fireworksRef}
        positionX={WIN_WIDTH/2}
        positionY={WIN_HEIGHT/2}
        particleSize={50}
        radius={100}
        innerRadius={40}
        radiusNoise={100}
        zIndex={100}
        iteration={1}
        numberOfParticle={10}
        particleColors={['red', 'blue', 'green']}
        autoStart={false}
        animationDuration={500}
        onAnimationDone={onAnimationDone}
        angleType={'random'}
      />

Image Type

<SLLFireworks
      ref={fireworksRef}
      positionX={WIN_WIDTH/2}
      positionY={WIN_HEIGHT/2}
      particleSize={50}
      radius={100}
      innerRadius={50}
      radiusNoise={100}
      zIndex={100}
      iteration={1}
      numberOfParticle={10}
      particleSources={[require('./star_01.png'), require('./star_02.png'), require('./star_03.png')]}
      autoStart={true}
      animationDuration={500}
      onAnimationDone={onAnimationDone}
      angleType={'equal'}
/>

Local Image, Server Image Mix Type

<SLLFireworks
        ref={fireworksRef}
        positionX={WIN_WIDTH/2}
        positionY={WIN_HEIGHT/2}
        particleSize={10}
        radius={100}
        innerRadius={0}
        radiusNoise={10}
        zIndex={100}
        iteration={1}
        numberOfParticle={100}
        particleSources={[require('./sample.png'), {uri: "https://img.icons8.com/ios/250/000000/rocket.png"}]}
        particleColors={['red', 'blue', 'green']}
        autoStart={false}
        animationDuration={500}
        onAnimationDone={onAnimationDone}
        angleType={'random'}
/>