Skip to content

Commit ce3a4d9

Browse files
committed
feat: version 2
1 parent e0b586d commit ce3a4d9

97 files changed

Lines changed: 20419 additions & 57697 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ module.exports = {
44
"eslint:recommended",
55
"plugin:react/recommended",
66
"plugin:@typescript-eslint/recommended",
7-
"@react-native-community",
87
"prettier",
98
],
109
ignorePatterns: [
@@ -25,16 +24,17 @@ module.exports = {
2524
"react-hooks",
2625
"@typescript-eslint",
2726
"promise",
28-
"jest",
2927
"unused-imports",
3028
],
3129
env: {
3230
browser: true,
3331
es2021: true,
34-
"jest/globals": true,
3532
"react-native/react-native": true,
3633
},
3734
settings: {
35+
react: {
36+
version: "detect",
37+
},
3838
"import/resolver": {
3939
node: {
4040
extensions: [
@@ -58,6 +58,14 @@ module.exports = {
5858
],
5959
},
6060
},
61+
// Ensure the import plugin does not try to parse node_modules with the TS parser
62+
"import/parsers": {
63+
"@typescript-eslint/parser": [".ts", ".tsx"],
64+
},
65+
// Treat react-native as a core module and skip deep parsing
66+
"import/core-modules": ["react-native"],
67+
// And in general, do not attempt to parse files in node_modules
68+
"import/ignore": ["node_modules/"],
6169
},
6270
rules: {
6371
quotes: [
@@ -80,10 +88,12 @@ module.exports = {
8088
constant: "always",
8189
},
8290
],
83-
"no-useless-catch": 0,
84-
"react-hooks/exhaustive-deps": 0,
91+
"react-hooks/exhaustive-deps": [
92+
"error",
93+
{ additionalHooks: "(useMemoOne)" },
94+
],
8595
"max-len": ["error", 120],
86-
"@typescript-eslint/ban-ts-comment": 1,
96+
"@typescript-eslint/ban-ts-comment": 2,
8797
"@typescript-eslint/no-empty-function": 0,
8898
"@typescript-eslint/no-explicit-any": 1,
8999
"@typescript-eslint/explicit-module-boundary-types": 0,
@@ -110,6 +120,8 @@ module.exports = {
110120
"import/no-deprecated": 0,
111121
"@typescript-eslint/indent": 0,
112122
"react-hooks/rules-of-hooks": 2,
123+
"unused-imports/no-unused-imports": 2,
124+
"unused-imports/no-unused-vars": 2,
113125
camelcase: 2,
114126
"prefer-destructuring": 2,
115127
"no-nested-ternary": 2,

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@noxx-mobile:registry=https://npm.pkg.github.com
2+
//npm.pkg.github.com/:_authToken=${NOXX_GITHUB_TOKEN}

README.md

Lines changed: 134 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<img alt="React Native Bounceable" src="assets/logo.png" width="1050"/>
1+
r<img alt="React Native Bounceable" src="assets/logo.png" width="1050"/>
22

33
[![Battle Tested ✅](https://img.shields.io/badge/-Battle--Tested%20%E2%9C%85-03666e?style=for-the-badge)](https://github.com/WrathChaos/react-native-bounceable)
44

@@ -49,16 +49,141 @@ You can put **ANY children component** inside the **RNBounceable** component, it
4949
</RNBounceable>
5050
```
5151

52+
## Basic Examples
53+
54+
### 1) Simple button
55+
56+
```jsx
57+
<RNBounceable
58+
onPress={() => console.log('Pressed!')}
59+
bounceEffectIn={0.92}
60+
bounceEffectOut={1}
61+
bounceVelocityIn={0.2}
62+
bounceVelocityOut={0.45}
63+
bouncinessIn={6}
64+
bouncinessOut={0}
65+
style={{
66+
backgroundColor: '#111827', paddingVertical: 12, paddingHorizontal: 16, borderRadius: 12,
67+
}}
68+
>
69+
<Text style={{ color: '#fff', fontWeight: '600' }}>Tap me</Text>
70+
</RNBounceable>
71+
```
72+
73+
### 2) Pressed feedback (function style)
74+
75+
```jsx
76+
<RNBounceable
77+
bounceEffectIn={0.97}
78+
bounceEffectOut={1}
79+
bounceVelocityIn={0.15}
80+
bounceVelocityOut={0.4}
81+
bouncinessIn={0}
82+
bouncinessOut={0}
83+
style={(state) => [{
84+
paddingVertical: 12, paddingHorizontal: 16, borderRadius: 12,
85+
backgroundColor: state.pressed ? '#0ea5e9' : '#3b82f6',
86+
}]}
87+
onPress={() => {}}
88+
>
89+
<Text style={{ color: '#fff', fontWeight: '600' }}>Pressed color</Text>
90+
</RNBounceable>
91+
```
92+
93+
### 3) Custom bounce tuning
94+
95+
```jsx
96+
<RNBounceable
97+
bounceEffectIn={0.88}
98+
bounceEffectOut={1}
99+
bounceVelocityIn={0.35}
100+
bounceVelocityOut={0.7}
101+
bouncinessIn={16}
102+
bouncinessOut={6}
103+
style={{ backgroundColor: '#22c55e', padding: 12, borderRadius: 12 }}
104+
>
105+
<Text style={{ color: '#fff', fontWeight: '700' }}>Custom spring</Text>
106+
</RNBounceable>
107+
```
108+
109+
### 4) Disabled (no bounce)
110+
111+
```jsx
112+
<RNBounceable disabled style={{
113+
backgroundColor: '#9ca3af', padding: 12, borderRadius: 12, opacity: 0.6,
114+
}}>
115+
<Text style={{ color: '#fff' }}>Disabled</Text>
116+
</RNBounceable>
117+
```
118+
119+
### 5) onPressIn / onPressOut
120+
121+
```jsx
122+
<RNBounceable
123+
bounceEffectIn={0.95}
124+
bounceEffectOut={1}
125+
bounceVelocityIn={0.25}
126+
bounceVelocityOut={0.5}
127+
bouncinessIn={10}
128+
bouncinessOut={0}
129+
onPressIn={() => console.log('press in')}
130+
onPressOut={() => console.log('press out')}
131+
style={{ backgroundColor: '#111827', padding: 12, borderRadius: 12 }}
132+
>
133+
<Text style={{ color: '#fff' }}>Press events</Text>
134+
</RNBounceable>
135+
```
136+
137+
### 6) Long press
138+
139+
```jsx
140+
<RNBounceable
141+
bounceEffectIn={0.85}
142+
bounceEffectOut={1}
143+
bounceVelocityIn={0.4}
144+
bounceVelocityOut={0.65}
145+
bouncinessIn={14}
146+
bouncinessOut={4}
147+
onLongPress={() => console.log('long press')}
148+
delayLongPress={300}
149+
style={{ backgroundColor: '#111827', padding: 12, borderRadius: 12 }}
150+
>
151+
<Text style={{ color: '#fff' }}>Hold me</Text>
152+
</RNBounceable>
153+
```
154+
155+
### 7) Icon / Image as child
156+
157+
```jsx
158+
<RNBounceable
159+
bounceEffectIn={0.9}
160+
bounceEffectOut={1}
161+
bounceVelocityIn={0.5}
162+
bounceVelocityOut={0.6}
163+
bouncinessIn={18}
164+
bouncinessOut={6}
165+
onPress={() => {}}
166+
style={{ height: 44, width: 44, borderRadius: 22, alignItems: 'center', justifyContent: 'center', backgroundColor: '#fff' }}
167+
>
168+
<Text style={{ fontSize: 20 }}>❤️</Text>
169+
</RNBounceable>
170+
```
171+
52172
# Configuration - Props
53173

54-
| Property | Type | Default | Description |
55-
| --------------- | :------: | :-------: | ------------------------------------------------ |
56-
| onPress | function | undefined | set your own logic for the onPress functionality |
57-
| style | style | undefined | set the style like any other View container |
58-
| bounceEffect | number | 0.9 | change the bounce effect's value |
59-
| bounceFriction | number | 3 | change the bounce effect's friction value |
60-
| useNativeDriver | boolean | true | change the useNativeDriver's usage |
61-
| animate | function | default | activate the bounce effect animation |
174+
| Property | Type | Default | Description |
175+
| ------------------ | :----------------: | :-----: | ---------------------------------------------------------- |
176+
| onPress | function | - | Callback for press |
177+
| style | Pressable `style` | - | Style object/array or function `(state) => style` |
178+
| bounceEffectIn | number | 0.93 | Scale value applied on press in |
179+
| bounceEffectOut | number | 1 | Scale value applied on press out |
180+
| bounceVelocityIn | number | 0.1 | Spring velocity for press in |
181+
| bounceVelocityOut | number | 0.4 | Spring velocity for press out |
182+
| bouncinessIn | number | 0 | Spring bounciness for press in |
183+
| bouncinessOut | number | 0 | Spring bounciness for press out |
184+
| useNativeDriver | boolean | true | Use native driver for animation |
185+
186+
All React Native `Pressable` props are supported and forwarded (including `onPressIn`, `onPressOut`, `disabled`, and `ref`). The bounce effect is skipped when `disabled` is true.
62187

63188
## Future Plans
64189

example/.buckconfig

Lines changed: 0 additions & 6 deletions
This file was deleted.

example/.bundle/config

Lines changed: 0 additions & 2 deletions
This file was deleted.

example/.eslintrc.js

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)