Skip to content

Commit fd23197

Browse files
authored
Merge pull request NativeScript#2950 from NativeScript/raikov/scale
Added support for scale(x)
2 parents 4045bb2 + 0292a49 commit fd23197

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

tns-core-modules/ui/styling/style.ts

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,8 @@ export class Style extends DependencyObservable implements styling.Style {
490490
}
491491

492492
get borderColor(): string | Color {
493-
if (Color.equals(this.borderTopColor, this.borderRightColor) &&
494-
Color.equals(this.borderTopColor, this.borderBottomColor) &&
493+
if (Color.equals(this.borderTopColor, this.borderRightColor) &&
494+
Color.equals(this.borderTopColor, this.borderBottomColor) &&
495495
Color.equals(this.borderTopColor, this.borderLeftColor)){
496496
return this.borderTopColor;
497497
}
@@ -535,8 +535,8 @@ export class Style extends DependencyObservable implements styling.Style {
535535
}
536536

537537
get borderWidth(): string | number {
538-
if (this.borderTopWidth === this.borderRightWidth &&
539-
this.borderTopWidth === this.borderBottomWidth &&
538+
if (this.borderTopWidth === this.borderRightWidth &&
539+
this.borderTopWidth === this.borderBottomWidth &&
540540
this.borderTopWidth === this.borderLeftWidth){
541541
return this.borderTopWidth;
542542
}
@@ -577,8 +577,8 @@ export class Style extends DependencyObservable implements styling.Style {
577577
}
578578

579579
get borderRadius(): string | number {
580-
if (this.borderTopLeftRadius === this.borderTopRightRadius &&
581-
this.borderTopLeftRadius === this.borderBottomRightRadius &&
580+
if (this.borderTopLeftRadius === this.borderTopRightRadius &&
581+
this.borderTopLeftRadius === this.borderBottomRightRadius &&
582582
this.borderTopLeftRadius === this.borderBottomLeftRadius){
583583
return this.borderTopLeftRadius;
584584
}
@@ -1275,10 +1275,14 @@ function onTransformChanged(value: any): Array<styleProperty.KeyValuePair<styleP
12751275
case "scale":
12761276
case "scale3d":
12771277
values = newTransform[transform].split(",");
1278-
if (values.length === 2 || values.length === 3) {
1278+
if (values.length >= 2) {
12791279
array.push({ property: scaleXProperty, value: parseFloat(values[0]) });
12801280
array.push({ property: scaleYProperty, value: parseFloat(values[1]) });
12811281
}
1282+
else if (values.length === 1) {
1283+
array.push({ property: scaleXProperty, value: parseFloat(values[0]) });
1284+
array.push({ property: scaleYProperty, value: parseFloat(values[0]) });
1285+
}
12821286
break;
12831287
case "translateX":
12841288
array.push({ property: translateXProperty, value: parseFloat(newTransform[transform]) });
@@ -1289,10 +1293,14 @@ function onTransformChanged(value: any): Array<styleProperty.KeyValuePair<styleP
12891293
case "translate":
12901294
case "translate3d":
12911295
values = newTransform[transform].split(",");
1292-
if (values.length === 2 || values.length === 3) {
1296+
if (values.length >= 2) {
12931297
array.push({ property: translateXProperty, value: parseFloat(values[0]) });
12941298
array.push({ property: translateYProperty, value: parseFloat(values[1]) });
12951299
}
1300+
else if (values.length === 1) {
1301+
array.push({ property: translateXProperty, value: parseFloat(values[0]) });
1302+
array.push({ property: translateYProperty, value: parseFloat(values[0]) });
1303+
}
12961304
break;
12971305
case "rotate":
12981306
let text = newTransform[transform];
@@ -1611,40 +1619,40 @@ function parseThickness(value: any): definition.Thickness {
16111619
if (types.isString(value)) {
16121620
let arr = value.split(/[ ,]+/);
16131621
if (arr.length === 1){
1614-
let arr0 = parseInt(arr[0]);
1622+
let arr0 = parseInt(arr[0]);
16151623
result.top = arr0;
16161624
result.right = arr0;
16171625
result.bottom = arr0;
16181626
result.left = arr0;
16191627
}
16201628
else if (arr.length === 2){
1621-
let arr0 = parseInt(arr[0]);
1622-
let arr1 = parseInt(arr[1]);
1629+
let arr0 = parseInt(arr[0]);
1630+
let arr1 = parseInt(arr[1]);
16231631
result.top = arr0;
16241632
result.right = arr1;
16251633
result.bottom = arr0;
16261634
result.left = arr1;
16271635
}
16281636
else if (arr.length === 3){
1629-
let arr0 = parseInt(arr[0]);
1630-
let arr1 = parseInt(arr[1]);
1631-
let arr2 = parseInt(arr[2]);
1637+
let arr0 = parseInt(arr[0]);
1638+
let arr1 = parseInt(arr[1]);
1639+
let arr2 = parseInt(arr[2]);
16321640
result.top = arr0;
16331641
result.right = arr1;
16341642
result.bottom = arr2;
16351643
result.left = arr1;
16361644
}
16371645
else if (arr.length === 4){
1638-
let arr0 = parseInt(arr[0]);
1639-
let arr1 = parseInt(arr[1]);
1640-
let arr2 = parseInt(arr[2]);
1641-
let arr3 = parseInt(arr[3]);
1646+
let arr0 = parseInt(arr[0]);
1647+
let arr1 = parseInt(arr[1]);
1648+
let arr2 = parseInt(arr[2]);
1649+
let arr3 = parseInt(arr[3]);
16421650
result.top = arr0;
16431651
result.right = arr1;
16441652
result.bottom = arr2;
16451653
result.left = arr3;
16461654
}
1647-
}
1655+
}
16481656
else if (types.isNumber(value)) {
16491657
result.top = result.right = result.bottom = result.left = value;
16501658
}
@@ -1661,7 +1669,7 @@ function parseBorderColor(value: any): definition.BorderColor {
16611669
if (types.isString(value)) {
16621670
if (value.indexOf("rgb") === 0){
16631671
result.top = result.right = result.bottom = result.left = new Color(value);
1664-
return result;
1672+
return result;
16651673
}
16661674

16671675
let arr = value.split(/[ ,]+/);
@@ -1699,7 +1707,7 @@ function parseBorderColor(value: any): definition.BorderColor {
16991707
result.bottom = arr2;
17001708
result.left = arr3;
17011709
}
1702-
}
1710+
}
17031711
else if (value instanceof Color) {
17041712
result.top = result.right = result.bottom = result.left = value;
17051713
}

0 commit comments

Comments
 (0)