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 {
const nativeView: NativeScriptUIView = <NativeScriptUIView>this.nativeViewProtected;
if (nativeView) {
const frame = nativeView.frame;
const needsUpdate: boolean = nativeView.outerShadowContainerLayer != null;
if (nativeView?.outerShadowContainerLayer) {
CATransaction.setDisableActions(true);
if (needsUpdate) {
CATransaction.setDisableActions(true);
nativeView.outerShadowContainerLayer.bounds = nativeView.bounds;
nativeView.outerShadowContainerLayer.position = nativeView.center;
if (nativeView.outerShadowContainerLayer) {
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);
}
CATransaction.setDisableActions(false);
}
}

View File

@ -1091,7 +1091,6 @@ function drawBoxShadow(view: View): void {
}
const bounds = nativeView.bounds;
const viewFrame = nativeView.frame;
const boxShadow: BoxShadow = background.getBoxShadow();
// Initialize outer shadows
@ -1127,10 +1126,7 @@ function drawBoxShadow(view: View): void {
outerShadowContainerLayer.bounds = bounds;
outerShadowContainerLayer.anchorPoint = layer.anchorPoint;
// 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);
outerShadowContainerLayer.position = nativeView.center;
// Inherit view visibility values
outerShadowContainerLayer.opacity = layer.opacity;