Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Degrees/Radians are being mixed up #73

Open
Jeffdude opened this issue Jun 6, 2024 · 0 comments
Open

[Bug] Degrees/Radians are being mixed up #73

Jeffdude opened this issue Jun 6, 2024 · 0 comments

Comments

@Jeffdude
Copy link

Jeffdude commented Jun 6, 2024

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:

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:
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.

@Jeffdude Jeffdude changed the title [Bug] Degress/Radians are being mixed up [Bug] Degrees/Radians are being mixed up Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant