Created
April 18, 2018 21:18
-
-
Save jarvisluong/c696e88cf01b7a2eb7ff8072d67da59e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React from 'react'; | |
import {TouchableWithoutFeedback, Text, View} from 'react-native'; | |
import * as Animatable from 'react-native-animatable'; | |
Animatable.initializeRegistryWithDefinitions({ | |
bounceLeftRight: { | |
0: { | |
translateX: 0, | |
}, | |
0.3: { | |
translateX: -25, | |
}, | |
0.6: { | |
translateX: 0, | |
}, | |
0.8: { | |
translateX: 25, | |
}, | |
1: { | |
translateX: 0, | |
}, | |
}, | |
bounceLeft: { | |
0: { | |
translateX: 0, | |
}, | |
0.3: { | |
translateX: -25, | |
}, | |
0.6: { | |
translateX: 0, | |
}, | |
0.8: { | |
translateX: -25, | |
}, | |
1: { | |
translateX: 0, | |
}, | |
}, | |
bounceRight: { | |
0: { | |
translateX: 0, | |
}, | |
0.3: { | |
translateX: 25, | |
}, | |
0.6: { | |
translateX: 0, | |
}, | |
0.8: { | |
translateX: 25, | |
}, | |
1: { | |
translateX: 0, | |
}, | |
} | |
}); | |
export default class Bounce extends React.Component { | |
handleViewRef = ref => this.view = ref; | |
bounce = () => this.view.bounceLeftRight(800); | |
render() { | |
return ( | |
<TouchableWithoutFeedback onPress={this.bounce}> | |
<Animatable.View ref={this.handleViewRef}> | |
{this.props.children} | |
</Animatable.View> | |
</TouchableWithoutFeedback> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment