Rename pixels to points

This commit is contained in:
David Hart
2017-02-03 20:46:12 +01:00
parent b5c2b09780
commit 9f192b0372
17 changed files with 186 additions and 165 deletions

View File

@@ -86,7 +86,7 @@ module.exports = {
UNIT_COUNT: 3,
UNIT_UNDEFINED: 0,
UNIT_PIXEL: 1,
UNIT_POINT: 1,
UNIT_PERCENT: 2,
WRAP_COUNT: 2,

View File

@@ -102,7 +102,7 @@ module.exports = function (bind, lib) {
switch (this.unit) {
case constants.UNIT_PIXEL:
case constants.UNIT_POINT:
return `${this.value}`;
case constants.UNIT_PERCENT:
@@ -126,7 +126,7 @@ module.exports = function (bind, lib) {
for (let fnName of [ `setPosition`, `setMargin`, `setFlexBasis`, `setWidth`, `setHeight`, `setMinWidth`, `setMinHeight`, `setMaxWidth`, `setMaxHeight`, `setPadding` ]) {
let methods = { [constants.UNIT_PIXEL]: lib.Node.prototype[fnName], [constants.UNIT_PERCENT]: lib.Node.prototype[`${fnName}Percent`] };
let methods = { [constants.UNIT_POINT]: lib.Node.prototype[fnName], [constants.UNIT_PERCENT]: lib.Node.prototype[`${fnName}Percent`] };
if (Object.keys(methods).some(method => methods[method] == null))
throw new Error(`Assertion failed; some unit derivates of ${fnName} seem missing`);
@@ -146,7 +146,7 @@ module.exports = function (bind, lib) {
} else {
unit = typeof value === `string` && value.endsWith(`%`) ? constants.UNIT_PERCENT : constants.UNIT_PIXEL;
unit = typeof value === `string` && value.endsWith(`%`) ? constants.UNIT_PERCENT : constants.UNIT_POINT;
asNumber = parseFloat(value);
}