Skip to content
New issue

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

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

Already on GitHub? # to your account

When I use cm as units. It creates long numbers with decimals. #26

Open
ram4nd opened this issue Feb 14, 2022 · 1 comment
Open

When I use cm as units. It creates long numbers with decimals. #26

ram4nd opened this issue Feb 14, 2022 · 1 comment

Comments

@ram4nd
Copy link

ram4nd commented Feb 14, 2022

When I use cm as units. It creates long numbers with decimals. Imo this should be rounded away.

Here is the diff that solved my problem:

diff --git a/node_modules/@scena/react-ruler/src/react-ruler/Ruler.tsx b/node_modules/@scena/react-ruler/src/react-ruler/Ruler.tsx
index 8a32e3e..946fa48 100644
--- a/node_modules/@scena/react-ruler/src/react-ruler/Ruler.tsx
+++ b/node_modules/@scena/react-ruler/src/react-ruler/Ruler.tsx
@@ -163,10 +163,10 @@ export default class Ruler extends React.PureComponent<RulerProps> implements Ru
                     ? [startPos + alignOffset * -3, isDirectionStart ? 17 : height - 17]
                     : [isDirectionStart ? 17 : width - 17, startPos + alignOffset * 3];
 
-                let text = `${value * unit}`;
+                let text = String(Math.round(value * unit));
 
                 if (textFormat) {
-                    text = textFormat(value * unit);
+                    text = textFormat(text);
                 }
 
                 context.textAlign = textAlign;

This issue body was partially generated by patch-package.

@daybrush
Copy link
Owner

daybrush commented Mar 6, 2022

@ram4nd

usetextFormat prop.

textFormat={value => Math.round(value)}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants