Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/core/ui/animation/index.windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function _resolveAnimationCurve(curve: any): any {
import { AnimationBase, Properties } from './animation-common';
import type { View } from '../core/view';
//@ts-ignore
import { _ensureNativeTransforms } from '../core/view/index';
import { _ensureNativeTransforms } from '../core/view/native-transforms.windows';

function _applyFinalValue(target: any, property: string, to: any): void {
try {
Expand Down
22 changes: 2 additions & 20 deletions packages/core/ui/core/view/index.windows.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './view-common';
export * from './view-helper';
export * from '../properties';
export { _ensureNativeTransforms } from './native-transforms.windows';

import { ViewCommon, originXProperty, originYProperty } from './view-common';
import type { CoreTypes } from '../../../core-types';
Expand All @@ -18,6 +19,7 @@ import { getClientOriginOnScreen, getCurrentWindowBounds, getCurrentWindowConten
import { ImageSource } from '../../../image-source';
import { ClipPathFunction } from '../../styling/clip-path-function';
import { nativeChildIndex, removeNativeChild } from './native-children.windows';
import { _ensureNativeTransforms } from './native-transforms.windows';
type WindowsColor = Color & { windows: Windows.UI.Color, windowsArgb: number };

// Windows.UI.Color is a plain {A,R,G,B} struct. Bridge reads fields directly, no WinRT call needed.
Expand Down Expand Up @@ -91,26 +93,6 @@ function _resolveToWinColor(color: any): Windows.UI.Color | null {
}


export function _ensureNativeTransforms(native: any): { scale: any; rotate: any; translate: any } | null {
try {
if (native.__ns_transforms) return native.__ns_transforms;

const tg = new Microsoft.UI.Xaml.Media.TransformGroup();
const scale = new Microsoft.UI.Xaml.Media.ScaleTransform();
const rotate = new Microsoft.UI.Xaml.Media.RotateTransform();
const translate = new Microsoft.UI.Xaml.Media.TranslateTransform();
tg.Children.Append(scale);
tg.Children.Append(rotate);
tg.Children.Append(translate);
native.RenderTransform = tg;
const result = { scale, rotate, translate };
native.__ns_transforms = result;
return result;
} catch (_e) {
return null;
}
}

const hidden = Symbol('[[hidden]]');
function setVisibility(nativeView: Microsoft.UI.Xaml.UIElement & { [hidden]?: boolean }, value: CoreTypes.VisibilityType) {
switch (value) {
Expand Down
19 changes: 19 additions & 0 deletions packages/core/ui/core/view/native-transforms.windows.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export function _ensureNativeTransforms(native: any): { scale: any; rotate: any; translate: any } | null {
try {
if (native.__ns_transforms) return native.__ns_transforms;

const tg = new Microsoft.UI.Xaml.Media.TransformGroup();
const scale = new Microsoft.UI.Xaml.Media.ScaleTransform();
const rotate = new Microsoft.UI.Xaml.Media.RotateTransform();
const translate = new Microsoft.UI.Xaml.Media.TranslateTransform();
tg.Children.Append(scale);
tg.Children.Append(rotate);
tg.Children.Append(translate);
native.RenderTransform = tg;
const result = { scale, rotate, translate };
native.__ns_transforms = result;
return result;
} catch (_e) {
return null;
}
}
Loading