-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Percentages are handled in confusing way #81
Comments
Good proposal. |
Sorry If my english makes you all confused. tryCalcViewport(str) {
let vpprop = null;
if(str.endsWith("vw")) {
vpprop = "width";
}
else if(str.endsWith("vh")) {
vpprop = "height";
}
else if(str.endsWith("vp")) {
vpprop = this.prop;
}
if(vpprop != null) {
let val = str.substr(0, str.length-2)+"%"
return percent.calc(val, vpprop);
}
return null;
} and insert function into action array at calcString and calcOperandValue calcString() {
let actions = [
this.tryCalcOperation,
this.tryCalcViewport, // <<<<<<<<<<<<<<<<<<< insert here
this.isOperation ? this.tryCalcPercent : null,
this.tryCalcVar,
this.tryCalcRem,
].filter(Boolean);
let value = this.tryActions(actions, this.value);
if (value !== null) {
this.outValue = value;
} else {
this.proxyValue();
}
} and calcOperandValue(str) {
let actions = [
this.tryCalcVar,
this.tryCalcViewport, // <<<<<<<<<<<<<<<<<<< insert here
this.tryCalcPercent,
this.tryCalcRem,
this.tryCalcFloat,
];
return this.tryActions(actions, str);
} Now I can use vw vh and still use %. Especially I create vp to force calculate by prop name same as % do. Here is my code |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi! |
Here are possible solutions: https://stackoverflow.com/questions/52449976/how-to-use-vw-and-vh-css-with-react-native |
The way library handles it right now seems to be confusing. How about splitting percentages based on parent and screen to two (or three) separate units.
My proposal would be to handle it the way it's working on the web, so:
X%
- uses native RN implementation.Xvw
- uses screen's widthXvh
- uses screen's heightThe text was updated successfully, but these errors were encountered: