Skip to content

Commit 1d85cd3

Browse files
authored
Fix contextualExpanding (#189)
1 parent c493eb0 commit 1d85cd3

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Sources/FluidStack/Transition/AddingPresets/AnyAddingTransition+contextualExpanding.swift

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ extension AnyAddingTransition {
99
) -> Self {
1010

1111
return .init { (context: AddingTransitionContext) in
12-
12+
1313
let entrypointSnapshotView = AnyMirrorViewProvider.portal(view: entrypointView, hidesSourceOnUsing: true).view()
14-
14+
1515
let maskView = UIView()
1616
maskView.backgroundColor = .black
1717

1818
if context.contentView.backgroundColor == nil {
1919
context.contentView.backgroundColor = .clear
2020
}
21-
21+
2222
//Fluid.doIfNotAnimating(view: context.toViewController.view) { _ in
2323
do {
2424
maskView.frame = context.toViewController.view.bounds
@@ -51,8 +51,18 @@ extension AnyAddingTransition {
5151
/// make initial state for displaying view
5252
let translation = Geometry.centerAndScale(from: context.contentView.bounds, to: fromFrame)
5353

54-
context.toViewController.view.transform = .init(scaleX: translation.scale.x, y: translation.scale.y)
55-
context.toViewController.view.center = translation.center
54+
// Use transform translation instead of view.center to avoid breaking UIKeyboardLayoutGuide
55+
let currentCenter = context.toViewController.view.center
56+
let offset = CGPoint(
57+
x: translation.center.x - currentCenter.x,
58+
y: translation.center.y - currentCenter.y
59+
)
60+
61+
// Combine scale and translation
62+
// Note: translate amount is scaled, so we need to divide by scale
63+
context.toViewController.view.transform = CGAffineTransform(scaleX: translation.scale.x, y: translation.scale.y)
64+
.translatedBy(x: offset.x / translation.scale.x, y: offset.y / translation.scale.y)
65+
5666
context.toViewController.view.alpha = 0.2
5767

5868
// fix visually height against transforming

0 commit comments

Comments
 (0)