Skip to content

Commit cd135b3

Browse files
scenee0x1306a94
andcommitted
Fix scroll offset reset due to floating-point precision errors (#677)
When the panel is already at a boundary position, floating-point precision errors on some devices (like iPhone 17 Pro Max) can cause unexpected offset resets in the position calculation. This commit addresses the layout issue where fractional values caused incorrect position evaluation. Based on the initial fix and sample project provided by @0x1306a94. Co-authored-by: 0x1306a94 <onyxes_accent_0a@icloud.com>
1 parent 9e8fd34 commit cd135b3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/Layout.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class LayoutAdapter {
306306
}
307307

308308
func surfaceLocation(for state: FloatingPanelState) -> CGPoint {
309-
let pos = position(for: state).rounded(by: surfaceView.fp_displayScale)
309+
let pos = position(for: state)
310310
switch layout.position {
311311
case .top, .bottom:
312312
return CGPoint(x: 0.0, y: pos)
@@ -316,6 +316,10 @@ class LayoutAdapter {
316316
}
317317

318318
func position(for state: FloatingPanelState) -> CGFloat {
319+
return _position(for: state).rounded(by: surfaceView.fp_displayScale)
320+
}
321+
322+
private func _position(for state: FloatingPanelState) -> CGFloat {
319323
let bounds = vc.view.bounds
320324
let anchor = layout.anchors[state] ?? self.hiddenAnchor
321325

0 commit comments

Comments
 (0)