Skip to content

Commit 737f948

Browse files
committed
new: Animate function is available
1 parent 7a1bd84 commit 737f948

4 files changed

Lines changed: 9 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ You can put **ANY children component** inside the **RNBounceable** component, it
5252
| bounceEffect | number | 0.9 | change the bounce effect's value |
5353
| bounceFriction | number | 3 | change the bounce effect's friction value |
5454
| useNativeDriver | boolean | true | change the useNativeDriver's usage |
55+
| animate | function | default | activate the bounce effect animation |
5556

5657
## Future Plans
5758

-92.7 MB
Binary file not shown.

lib/RNBounceable.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,33 @@ export default class RNBounceable extends React.Component<
3333
};
3434
}
3535

36-
springAnimation = () => {
36+
animate = () => {
3737
const { springValue } = this.state;
3838
const {
3939
bounceEffect = 0.9,
4040
bounceFriction = 3,
4141
useNativeDriver = true,
42-
onPress,
4342
} = this.props;
4443
springValue.setValue(bounceEffect);
4544
Animated.spring(springValue, {
4645
toValue: 1,
4746
friction: bounceFriction,
4847
useNativeDriver,
4948
}).start();
49+
};
50+
51+
onPress = () => {
52+
this.animate();
5053
// ? Outside of the onPress function callback
51-
onPress && onPress();
54+
this.props.onPress && this.props.onPress();
5255
};
5356

5457
render() {
5558
const { children, style } = this.props;
5659
return (
5760
<TouchableWithoutFeedback
5861
{...this.props}
59-
onPress={this.springAnimation.bind(this, Easing.bounce)}
62+
onPress={this.onPress.bind(this, Easing.bounce)}
6063
>
6164
<Animated.View
6265
style={[{ transform: [{ scale: this.state.springValue }] }, style]}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@freakycoder/react-native-bounceable",
3-
"version": "0.2.4",
3+
"version": "0.2.5",
44
"description": "Animate and bounce any component with RNBounceable for React Native",
55
"main": "./build/dist/RNBounceable.js",
66
"repository": "git@github.com:WrathChaos/react-native-bounceable.git",

0 commit comments

Comments
 (0)