fix(ios): shadow position after translate transform (#10413)

This commit is contained in:
Dimitris-Rafail Katsampas
2023-10-17 01:41:59 +03:00
committed by GitHub
parent ee87b52ac3
commit c78ea79f0f
2 changed files with 6 additions and 18 deletions

View File

@ -155,21 +155,13 @@ export class View extends ViewCommon implements ViewDefinition {
private layoutOuterShadows(): void { private layoutOuterShadows(): void {
const nativeView: NativeScriptUIView = <NativeScriptUIView>this.nativeViewProtected; const nativeView: NativeScriptUIView = <NativeScriptUIView>this.nativeViewProtected;
if (nativeView) { if (nativeView?.outerShadowContainerLayer) {
const frame = nativeView.frame; CATransaction.setDisableActions(true);
const needsUpdate: boolean = nativeView.outerShadowContainerLayer != null;
if (needsUpdate) { nativeView.outerShadowContainerLayer.bounds = nativeView.bounds;
CATransaction.setDisableActions(true); nativeView.outerShadowContainerLayer.position = nativeView.center;
if (nativeView.outerShadowContainerLayer) { CATransaction.setDisableActions(false);
const { x: originX, y: originY }: CGPoint = nativeView.outerShadowContainerLayer.anchorPoint;
nativeView.outerShadowContainerLayer.bounds = nativeView.bounds;
nativeView.outerShadowContainerLayer.position = CGPointMake(frame.origin.x + frame.size.width * originX, frame.origin.y + frame.size.height * originY);
}
CATransaction.setDisableActions(false);
}
} }
} }

View File

@ -1091,7 +1091,6 @@ function drawBoxShadow(view: View): void {
} }
const bounds = nativeView.bounds; const bounds = nativeView.bounds;
const viewFrame = nativeView.frame;
const boxShadow: BoxShadow = background.getBoxShadow(); const boxShadow: BoxShadow = background.getBoxShadow();
// Initialize outer shadows // Initialize outer shadows
@ -1127,10 +1126,7 @@ function drawBoxShadow(view: View): void {
outerShadowContainerLayer.bounds = bounds; outerShadowContainerLayer.bounds = bounds;
outerShadowContainerLayer.anchorPoint = layer.anchorPoint; outerShadowContainerLayer.anchorPoint = layer.anchorPoint;
outerShadowContainerLayer.position = nativeView.center;
// Since shadow uses superlayer's coordinate system, we have to be more specific about shadow layer position
const { x: originX, y: originY }: CGPoint = outerShadowContainerLayer.anchorPoint;
outerShadowContainerLayer.position = CGPointMake(viewFrame.origin.x + viewFrame.size.width * originX, viewFrame.origin.y + viewFrame.size.height * originY);
// Inherit view visibility values // Inherit view visibility values
outerShadowContainerLayer.opacity = layer.opacity; outerShadowContainerLayer.opacity = layer.opacity;