From 79715025e3715cebd506c0a8751bfcd50dd66efc Mon Sep 17 00:00:00 2001 From: 0x1306a94 <0x1306a94@gmail.com> Date: Tue, 13 Jan 2026 10:14:50 +0800 Subject: [PATCH] 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. --- Sources/Core.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Core.swift b/Sources/Core.swift index 659ca72c..5340ae0f 100644 --- a/Sources/Core.swift +++ b/Sources/Core.swift @@ -432,7 +432,7 @@ class Core: NSObject, UIGestureRecognizerDelegate { let velocity = value(of: panGesture.velocity(in: panGesture.view)) let location = panGesture.location(in: surfaceView) - let insideMostExpandedAnchor = 0 < layoutAdapter.offsetFromMostExpandedAnchor + let insideMostExpandedAnchor = 0 < floor(layoutAdapter.offsetFromMostExpandedAnchor) os_log(msg, log: devLog, type: .debug, """ scroll gesture(\(state):\(panGesture.state)) -- \ @@ -927,7 +927,7 @@ class Core: NSObject, UIGestureRecognizerDelegate { } private func shouldAttract(to state: FloatingPanelState) -> Bool { - if layoutAdapter.position(for: state) == value(of: layoutAdapter.surfaceLocation) { + if floor(layoutAdapter.position(for: state)) == floor(value(of: layoutAdapter.surfaceLocation)) { return false } return true