Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/ui/core/view/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,6 @@ export abstract class View extends ViewCommon {
*/
scaleY: number;

//END Style property shortcuts

/**
* Gets or sets the X component of the origin point around which the view will be transformed. The default value is 0.5 representing the center of the view.
*
Expand All @@ -603,6 +601,8 @@ export abstract class View extends ViewCommon {
*/
originY: number;

//END Style property shortcuts

/**
* The flex-flow Shorthand property specifies the direction of a flex container, as well as its wrapping behavior.
* @nsProperty
Expand Down
30 changes: 14 additions & 16 deletions packages/core/ui/core/view/view-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,20 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
this.style.translateY = value;
}

get originX(): number {
return this.style.originX;
}
set originX(value: number) {
this.style.originX = value;
}

get originY(): number {
return this.style.originY;
}
set originY(value: number) {
this.style.originY = value;
}

get scaleX(): number {
return this.style.scaleX;
}
Expand Down Expand Up @@ -979,8 +993,6 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {

//END Style property shortcuts

public originX: number;
public originY: number;
public isEnabled: boolean;
public isUserInteractionEnabled: boolean;
public iosOverflowSafeArea: boolean;
Expand Down Expand Up @@ -1256,20 +1268,6 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
}
}

export const originXProperty = new Property<ViewCommon, number>({
name: 'originX',
defaultValue: 0.5,
valueConverter: (v) => parseFloat(v),
});
originXProperty.register(ViewCommon);

export const originYProperty = new Property<ViewCommon, number>({
name: 'originY',
defaultValue: 0.5,
valueConverter: (v) => parseFloat(v),
});
originYProperty.register(ViewCommon);

export const isEnabledProperty = new Property<ViewCommon, boolean>({
name: 'isEnabled',
defaultValue: true,
Expand Down
35 changes: 35 additions & 0 deletions packages/core/ui/styling/style-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,22 @@ export const perspectiveProperty = new CssAnimationProperty<Style, number>({
});
perspectiveProperty.register(Style);

export const originXProperty = new CssProperty<Style, number>({
name: 'originX',
cssName: 'origin-x',
defaultValue: 0.5,
valueConverter: parseFloat,
});
originXProperty.register(Style);

export const originYProperty = new CssProperty<Style, number>({
name: 'originY',
cssName: 'origin-y',
defaultValue: 0.5,
valueConverter: parseFloat,
});
originYProperty.register(Style);

export const scaleXProperty = new CssAnimationProperty<Style, number>({
name: 'scaleX',
cssName: 'scaleX',
Expand Down Expand Up @@ -673,6 +689,25 @@ export const translateYProperty = new CssAnimationProperty<Style, CoreTypes.Fixe
});
translateYProperty.register(Style);

const transformOriginProperty = new ShorthandProperty<Style, string>({
name: 'transformOrigin',
cssName: 'transform-origin',

getter(this: Style) {
return `${this.originX} ${this.originY}`;
},

converter(value: string) {
const [x, y] = value.trim().split(/\s+/).map(parseFloat);
return [
[originXProperty, isNaN(x) ? 0.5 : x],
[originYProperty, isNaN(y) ? 0.5 : y],
];
},
});

transformOriginProperty.register(Style);

const transformProperty = new ShorthandProperty<Style, string>({
name: 'transform',
cssName: 'transform',
Expand Down
3 changes: 3 additions & 0 deletions packages/core/ui/styling/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export class Style extends Observable {
public fontScaleInternal: number;
public backgroundInternal: Background;

public originX: number;
public originY: number;

public rotate: number;
public rotateX: number;
public rotateY: number;
Expand Down