-
Notifications
You must be signed in to change notification settings - Fork 67
Description
Hi there! Thank you for your work on this project. I noticed one issue that I'm having to patch for my purposes, where the rotationFunction's output is being treated like radians here:
react-native-wheely/src/WheelPickerItem.tsx
Lines 44 to 48 in 4a13bfb
| let y = | |
| (height / 2) * (1 - Math.sin(Math.PI / 2 - rotationFunction(i))); | |
| for (let j = 1; j < i; j++) { | |
| y += height * (1 - Math.sin(Math.PI / 2 - rotationFunction(j))); | |
| } |
While simultaneously being treated like degress here:
react-native-wheely/src/WheelPickerItem.tsx
Lines 108 to 111 in 4a13bfb
| const y = rotationFunction(x); | |
| range.unshift(`${y}deg`); | |
| range.push(`${y}deg`); | |
| } |
My fix for this is simply to rename deg to rad on L109,L110. Full diff is here:
diff --git a/node_modules/react-native-wheely/lib/WheelPickerItem.js b/node_modules/react-native-wheely/lib/WheelPickerItem.js
index 48e7962..b3d1278 100644
--- a/node_modules/react-native-wheely/lib/WheelPickerItem.js
+++ b/node_modules/react-native-wheely/lib/WheelPickerItem.js
@@ -78,11 +78,11 @@ const WheelPickerItem = ({ textStyle, style, height, option, index, visibleRest,
return range;
})(),
outputRange: (() => {
- const range = ['0deg'];
+ const range = ['0rad'];
for (let x = 1; x <= visibleRest + 1; x++) {
const y = rotationFunction(x);
- range.unshift(`${y}deg`);
- range.push(`${y}deg`);
+ range.unshift(`${y}rad`);
+ range.push(`${y}rad`);
}
return range;
})(),Now I am able to specify rotationFunction={(x) => x*(Math.PI/6)} with visibleRest = 2 meaning that each step is 30 degrees, and the last visible item is rotated 90 degrees, giving my wheel the impression of a true wheel.
If you'd like, I can put up a PR for this fix, as well as adjusting the default of the rotation function to be... (x) => x*(Math.PI/(2*visibleRest)).
Let me know if you have any further questions, or need any more information from me.