-
Notifications
You must be signed in to change notification settings - Fork 16
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
Incompatible with units #4
Comments
Every argument for math functions must be an unitless number. Except for the trigonometric functions, they allow So you need to:
|
I can imagine why you would not implement unit compatibility to make things easier. I know I could do
but this requires more variables and is therefor imho less clean. Wouldn't it be nice to be able to pass the unit into the math functions directly? Think of it as a feature request ;) My particular use case is this: I want to append an element to a div (using :after) and rotate it 45° to make an arrow-point. However, I want the diagonal of the rotated element to be exactly as high as the height of the original div. Therefor, I use pythagoras' theorem to calculate the width and height for the :after element necessary to make it the right height after rotation. The math should check out and resolve to the proper output unit (ems to ems, px to px), but now I have to strip the unit before applying the math and then reapply the unit, taking into account measures for when the unit might change during development... |
I have to agree. Sass is built around being able to perform calculations with units. |
@call-a3 @Undistraction Thanks for your feedback. Let me think about it! |
I don't think this is possible. Sass can only express units with whole exponents, e.g. I think it is possible in many cases to restructure the formular so this is actually not required. For example, the original example can be converted to this: $side: 2em;
width: (abs($side) / sqrt(2)); Also note that the current implementations are focused on floating point numbers. This means that they are good estimations in general, but there is no guarantee that Finally, I was interested about the current behavior:
|
btw wrong Result of cos(180)*100 must return -100 but it is returns "74.69988" ??!!! |
If no unit is provided, |
no unit is provided. |
Either I'm misunderstanding the usage of these functions, or they are unusable with units such as em or px. I tried the following:
which fails with the following error: node_modules/mathsass/dist/functions/pow:13: error: cannot add or subtract numbers with incompatible units
The text was updated successfully, but these errors were encountered: