From 0292a49ea22069de2fae0b249b4f20fbc39c91af Mon Sep 17 00:00:00 2001 From: Tsvetan Raikov Date: Mon, 24 Oct 2016 16:42:45 +0300 Subject: [PATCH] Added support for scale(x) --- tns-core-modules/ui/styling/style.ts | 50 ++++++++++++++++------------ 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/tns-core-modules/ui/styling/style.ts b/tns-core-modules/ui/styling/style.ts index 7a5bee76a..03cea169e 100644 --- a/tns-core-modules/ui/styling/style.ts +++ b/tns-core-modules/ui/styling/style.ts @@ -490,8 +490,8 @@ export class Style extends DependencyObservable implements styling.Style { } get borderColor(): string | Color { - if (Color.equals(this.borderTopColor, this.borderRightColor) && - Color.equals(this.borderTopColor, this.borderBottomColor) && + if (Color.equals(this.borderTopColor, this.borderRightColor) && + Color.equals(this.borderTopColor, this.borderBottomColor) && Color.equals(this.borderTopColor, this.borderLeftColor)){ return this.borderTopColor; } @@ -535,8 +535,8 @@ export class Style extends DependencyObservable implements styling.Style { } get borderWidth(): string | number { - if (this.borderTopWidth === this.borderRightWidth && - this.borderTopWidth === this.borderBottomWidth && + if (this.borderTopWidth === this.borderRightWidth && + this.borderTopWidth === this.borderBottomWidth && this.borderTopWidth === this.borderLeftWidth){ return this.borderTopWidth; } @@ -577,8 +577,8 @@ export class Style extends DependencyObservable implements styling.Style { } get borderRadius(): string | number { - if (this.borderTopLeftRadius === this.borderTopRightRadius && - this.borderTopLeftRadius === this.borderBottomRightRadius && + if (this.borderTopLeftRadius === this.borderTopRightRadius && + this.borderTopLeftRadius === this.borderBottomRightRadius && this.borderTopLeftRadius === this.borderBottomLeftRadius){ return this.borderTopLeftRadius; } @@ -1229,10 +1229,14 @@ function onTransformChanged(value: any): Array= 2) { array.push({ property: scaleXProperty, value: parseFloat(values[0]) }); array.push({ property: scaleYProperty, value: parseFloat(values[1]) }); } + else if (values.length === 1) { + array.push({ property: scaleXProperty, value: parseFloat(values[0]) }); + array.push({ property: scaleYProperty, value: parseFloat(values[0]) }); + } break; case "translateX": array.push({ property: translateXProperty, value: parseFloat(newTransform[transform]) }); @@ -1243,10 +1247,14 @@ function onTransformChanged(value: any): Array= 2) { array.push({ property: translateXProperty, value: parseFloat(values[0]) }); array.push({ property: translateYProperty, value: parseFloat(values[1]) }); } + else if (values.length === 1) { + array.push({ property: translateXProperty, value: parseFloat(values[0]) }); + array.push({ property: translateYProperty, value: parseFloat(values[0]) }); + } break; case "rotate": let text = newTransform[transform]; @@ -1565,40 +1573,40 @@ function parseThickness(value: any): definition.Thickness { if (types.isString(value)) { let arr = value.split(/[ ,]+/); if (arr.length === 1){ - let arr0 = parseInt(arr[0]); + let arr0 = parseInt(arr[0]); result.top = arr0; result.right = arr0; result.bottom = arr0; result.left = arr0; } else if (arr.length === 2){ - let arr0 = parseInt(arr[0]); - let arr1 = parseInt(arr[1]); + let arr0 = parseInt(arr[0]); + let arr1 = parseInt(arr[1]); result.top = arr0; result.right = arr1; result.bottom = arr0; result.left = arr1; } else if (arr.length === 3){ - let arr0 = parseInt(arr[0]); - let arr1 = parseInt(arr[1]); - let arr2 = parseInt(arr[2]); + let arr0 = parseInt(arr[0]); + let arr1 = parseInt(arr[1]); + let arr2 = parseInt(arr[2]); result.top = arr0; result.right = arr1; result.bottom = arr2; result.left = arr1; } else if (arr.length === 4){ - let arr0 = parseInt(arr[0]); - let arr1 = parseInt(arr[1]); - let arr2 = parseInt(arr[2]); - let arr3 = parseInt(arr[3]); + let arr0 = parseInt(arr[0]); + let arr1 = parseInt(arr[1]); + let arr2 = parseInt(arr[2]); + let arr3 = parseInt(arr[3]); result.top = arr0; result.right = arr1; result.bottom = arr2; result.left = arr3; } - } + } else if (types.isNumber(value)) { result.top = result.right = result.bottom = result.left = value; } @@ -1615,7 +1623,7 @@ function parseBorderColor(value: any): definition.BorderColor { if (types.isString(value)) { if (value.indexOf("rgb") === 0){ result.top = result.right = result.bottom = result.left = new Color(value); - return result; + return result; } let arr = value.split(/[ ,]+/); @@ -1653,7 +1661,7 @@ function parseBorderColor(value: any): definition.BorderColor { result.bottom = arr2; result.left = arr3; } - } + } else if (value instanceof Color) { result.top = result.right = result.bottom = result.left = value; }