react-native-pulsating-circle
React Native component for creating an animated pulsing circle. Useful as an activity indicator. Works on iOS & Android.
Example app
Installation
- Install the component:
npm i --save react-native-pulsating-circle
Usage
Import PulsatingCircle:
Use as follows:
<PulsatingCircle />
You can also supply any of the following properties:
<PulsatingCircle = = = = = = = = = =/>
You can wrap children components to be displayed inside the circle:
<PulsatingCircle> <Text = > $45 </Text></PulsatingCircle>
You can define an onPress to fire your method when the circle is pressed:
{ } { return <PulsatingCircle = /> }
Finally, you can manually trigger animation start, animation stop and toggle animation by adding a ref like so:
{ thisrefsmyCircle thisrefsmyCircle thisrefsmyCircle};<PulsatingCircle ="myCircle" = />
thisrefsmyCircle // Will force the animation to startthisrefsmyCircle // Will force the animation to stopthisrefsmyCircle // if the animation is running, will stop the animation. Otherwise will start the animation
Configuration
You can configure the passing by following props:
- delay - number of milliseconds to pause between animation cycles (default: 3000)
- backgroundColor - color of the background for the component. If unspecified, no background will be rendered
- mainCircleBorder - border thickness of the primary circle (default: 1)
- mainCircleColor - color of the primary circle (default: #6cdbd2)
- mainCircleSize - height/width of the primary circle (default: 200)
- pulseCircleBorder - border thickness of the pulsating circle (default: 1)
- pulseCircleColor - color of the pulsating circle (default: #6cdbd2)
- pulseCircleSize - height/width of the primary circle (default: 200)
- playAnimation - indicates whether the animation should be playing or not (default: true)
- toggleOnPress - indicates if the animation should toggle on/off when clicked (default: false)
- onAnimationComplete - you can pass a callback function that will be invoked when the animation cycle completes.
- onPress - you can pass a callback function that will be invoked when the component is pressed. )
Author
Larry J Rutledge (larryjrutledge@gmail.com)
License
MIT
Special thanks
Special thansk to Spencer Carli for helping me understand React Native Animations and getting me a long ways down the road to making this specific animation work correctly.