-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add start, resume and stop API * Update flow config * Update example to start, resume and stop animation * Add unit tests
- Loading branch information
1 parent
e24c5b6
commit 46d98c2
Showing
6 changed files
with
195 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,51 @@ | ||
import React from 'react'; | ||
import { StyleSheet, Text, View } from 'react-native'; | ||
import * as React from 'react'; | ||
import { StyleSheet, Text, View, Button } from 'react-native'; | ||
import ConfettiCannon from 'react-native-confetti-cannon'; | ||
|
||
export default function App() { | ||
class App extends React.PureComponent { | ||
confettiCannon; | ||
|
||
handleAnimationStart = () => console.log('Animation start'); | ||
|
||
handleAnimationResume = () => console.log('Animation resume'); | ||
|
||
handleAnimationStop = () => console.log('Animation stop'); | ||
|
||
handleAnimationEnd = () => console.log('Animation end'); | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<ConfettiCannon | ||
count={200} | ||
origin={{x: -10, y: 0}} | ||
onAnimationStart={this.handleAnimationStart} | ||
onAnimationEnd={this.handleAnimationEnd} | ||
/> | ||
</View> | ||
); | ||
handleStartPress = () => this.confettiCannon.start(); | ||
|
||
handleResumePress = () => this.confettiCannon.resume(); | ||
|
||
handleStopPress = () => this.confettiCannon.stop(); | ||
|
||
render() { | ||
return ( | ||
<View style={styles.container}> | ||
<ConfettiCannon | ||
count={200} | ||
origin={{x: -10, y: 0}} | ||
onAnimationStart={this.handleAnimationStart} | ||
onAnimationResume={this.handleAnimationResume} | ||
onAnimationStop={this.handleAnimationStop} | ||
onAnimationEnd={this.handleAnimationEnd} | ||
ref={ref => this.confettiCannon = ref} | ||
/> | ||
<Button title="Start" onPress={this.handleStartPress} /> | ||
<Button title="Resume" onPress={this.handleResumePress} /> | ||
<Button title="Stop" onPress={this.handleStopPress} /> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
backgroundColor: '#fff', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
justifyContent: 'center' | ||
}, | ||
}); | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters