Skip to content

Commit eefc50e

Browse files
committed
Fix an invalid behavior after switching to a new layout object (#611)
1 parent dd23888 commit eefc50e

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

Sources/Core.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ class Core: NSObject, UIGestureRecognizerDelegate {
209209
contentOffset = scrollView?.contentOffset
210210
}
211211

212+
if layoutAdapter.validStates.contains(state) == false {
213+
state = layoutAdapter.initialState
214+
}
212215
layoutAdapter.updateStaticConstraint()
213216
layoutAdapter.activateLayout(for: state, forceLayout: forceLayout)
214217

@@ -725,7 +728,6 @@ class Core: NSObject, UIGestureRecognizerDelegate {
725728
}
726729

727730
guard shouldAttract(to: target) else {
728-
self.state = target
729731
self.updateLayout(to: target)
730732
self.unlockScrollView()
731733
// The `floatingPanelDidEndDragging(_:willAttract:)` must be called after the state property changes.

Sources/Layout.swift

-6
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,6 @@ class LayoutAdapter {
782782
NSLayoutConstraint.activate(constraint: self.fitToBoundsConstraint)
783783
}
784784

785-
var state = state
786-
787-
if validStates.contains(state) == false {
788-
state = layout.initialState
789-
}
790-
791785
// Recalculate the intrinsic size of a content view. This is because
792786
// UIView.systemLayoutSizeFitting() returns a different size between an
793787
// on-screen and off-screen view which includes

0 commit comments

Comments
 (0)