Commit f2121e72 authored by rockyl's avatar rockyl

支持range类型

parent ba414655
...@@ -25,6 +25,9 @@ function compute(props, options) { ...@@ -25,6 +25,9 @@ function compute(props, options) {
case 'vector2': case 'vector2':
value = parseVector2(sourceValue); value = parseVector2(sourceValue);
break; break;
case 'range':
value = parseRange(sourceValue);
break;
case 'array': case 'array':
var seps = sourceValue.split(','); var seps = sourceValue.split(',');
seps = seps.map(function (sep) { seps = seps.map(function (sep) {
...@@ -85,6 +88,26 @@ function parseVector2(sourceValue) { ...@@ -85,6 +88,26 @@ function parseVector2(sourceValue) {
} }
return value; return value;
} }
function parseRange(sourceValue) {
var value = sourceValue;
if (!sourceValue) {
value = { x: undefined, y: undefined };
}
if (typeof sourceValue === 'string') {
var arr = sourceValue.split(',');
value = {
min: arr[0] === '' ? undefined : parseFloat(arr[0]),
max: arr[1] === '' ? undefined : parseFloat(arr[1]),
};
}
else if (Array.isArray(sourceValue)) {
value = {
min: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),
max: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),
};
}
return value;
}
function getValue(props, option, key) { function getValue(props, option, key) {
var value; var value;
if (props.hasOwnProperty(key)) { if (props.hasOwnProperty(key)) {
...@@ -96,5 +119,5 @@ function getValue(props, option, key) { ...@@ -96,5 +119,5 @@ function getValue(props, option, key) {
return value; return value;
} }
export { compute, parseType, parseVector2 }; export { compute, parseRange, parseType, parseVector2 };
//# sourceMappingURL=index.es.js.map //# sourceMappingURL=index.es.js.map
This diff is collapsed.
...@@ -29,6 +29,9 @@ function compute(props, options) { ...@@ -29,6 +29,9 @@ function compute(props, options) {
case 'vector2': case 'vector2':
value = parseVector2(sourceValue); value = parseVector2(sourceValue);
break; break;
case 'range':
value = parseRange(sourceValue);
break;
case 'array': case 'array':
var seps = sourceValue.split(','); var seps = sourceValue.split(',');
seps = seps.map(function (sep) { seps = seps.map(function (sep) {
...@@ -89,6 +92,26 @@ function parseVector2(sourceValue) { ...@@ -89,6 +92,26 @@ function parseVector2(sourceValue) {
} }
return value; return value;
} }
function parseRange(sourceValue) {
var value = sourceValue;
if (!sourceValue) {
value = { x: undefined, y: undefined };
}
if (typeof sourceValue === 'string') {
var arr = sourceValue.split(',');
value = {
min: arr[0] === '' ? undefined : parseFloat(arr[0]),
max: arr[1] === '' ? undefined : parseFloat(arr[1]),
};
}
else if (Array.isArray(sourceValue)) {
value = {
min: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),
max: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),
};
}
return value;
}
function getValue(props, option, key) { function getValue(props, option, key) {
var value; var value;
if (props.hasOwnProperty(key)) { if (props.hasOwnProperty(key)) {
...@@ -101,6 +124,7 @@ function getValue(props, option, key) { ...@@ -101,6 +124,7 @@ function getValue(props, option, key) {
} }
exports.compute = compute; exports.compute = compute;
exports.parseRange = parseRange;
exports.parseType = parseType; exports.parseType = parseType;
exports.parseVector2 = parseVector2; exports.parseVector2 = parseVector2;
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map
This diff is collapsed.
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
case 'vector2': case 'vector2':
value = parseVector2(sourceValue); value = parseVector2(sourceValue);
break; break;
case 'range':
value = parseRange(sourceValue);
break;
case 'array': case 'array':
var seps = sourceValue.split(','); var seps = sourceValue.split(',');
seps = seps.map(function (sep) { seps = seps.map(function (sep) {
...@@ -91,6 +94,26 @@ ...@@ -91,6 +94,26 @@
} }
return value; return value;
} }
function parseRange(sourceValue) {
var value = sourceValue;
if (!sourceValue) {
value = { x: undefined, y: undefined };
}
if (typeof sourceValue === 'string') {
var arr = sourceValue.split(',');
value = {
min: arr[0] === '' ? undefined : parseFloat(arr[0]),
max: arr[1] === '' ? undefined : parseFloat(arr[1]),
};
}
else if (Array.isArray(sourceValue)) {
value = {
min: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),
max: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),
};
}
return value;
}
function getValue(props, option, key) { function getValue(props, option, key) {
var value; var value;
if (props.hasOwnProperty(key)) { if (props.hasOwnProperty(key)) {
...@@ -103,6 +126,7 @@ ...@@ -103,6 +126,7 @@
} }
exports.compute = compute; exports.compute = compute;
exports.parseRange = parseRange;
exports.parseType = parseType; exports.parseType = parseType;
exports.parseVector2 = parseVector2; exports.parseVector2 = parseVector2;
......
This diff is collapsed.
...@@ -31,6 +31,9 @@ export function compute(props, options: Object | Array<any>) { ...@@ -31,6 +31,9 @@ export function compute(props, options: Object | Array<any>) {
case 'vector2': case 'vector2':
value = parseVector2(sourceValue); value = parseVector2(sourceValue);
break; break;
case 'range':
value = parseRange(sourceValue);
break;
case 'array': case 'array':
let seps = sourceValue.split(','); let seps = sourceValue.split(',');
seps = seps.map(sep => { seps = seps.map(sep => {
...@@ -93,6 +96,26 @@ export function parseVector2(sourceValue) { ...@@ -93,6 +96,26 @@ export function parseVector2(sourceValue) {
return value; return value;
} }
export function parseRange(sourceValue) {
let value = sourceValue;
if (!sourceValue) {
value = {x: undefined, y: undefined};
}
if (typeof sourceValue === 'string') {
let arr = sourceValue.split(',');
value = {
min: arr[0] === '' ? undefined : parseFloat(arr[0]),
max: arr[1] === '' ? undefined : parseFloat(arr[1]),
};
} else if (Array.isArray(sourceValue)) {
value = {
min: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),
max: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),
};
}
return value;
}
function getValue(props, option, key) { function getValue(props, option, key) {
let value; let value;
if (props.hasOwnProperty(key)) { if (props.hasOwnProperty(key)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment