Skip to content

Commit 8899093

Browse files
committed
fix: Fix offset reset issue caused by floating-point precision at boundary positions
When the panel is already at a boundary position, floating-point precision errors on some devices can cause unexpected offset resets in the position calculation. By applying floor() to the position calculations for top, left, bottom, and right edges in FloatingPanelLayoutAnchor, we ensure integer values are returned, preventing layout issues caused by floating-point precision errors.
1 parent 9e8fd34 commit 8899093

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Sources/Layout.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,13 @@ class LayoutAdapter {
374374
let diff = anchor.isAbsolute ? anchor.inset : position.mainDimension(referenceBounds.size) * anchor.inset
375375
switch anchor.referenceEdge {
376376
case .top:
377-
return referenceBounds.minY + diff
377+
return floor(referenceBounds.minY + diff)
378378
case .left:
379-
return referenceBounds.minX + diff
379+
return floor(referenceBounds.minX + diff)
380380
case .bottom:
381-
return referenceBounds.maxY - diff
381+
return floor(referenceBounds.maxY - diff)
382382
case .right:
383-
return referenceBounds.maxX - diff
383+
return floor(referenceBounds.maxX - diff)
384384
}
385385
default:
386386
fatalError("Unsupported a FloatingPanelLayoutAnchoring object")

0 commit comments

Comments
 (0)