Closed i-arun-samui closed 3 years ago
Specify the panel move's boundary will help you.
Hi,
Thanks for your answer,
To suit my need I finally change FloatingPanelStates, this way (adding 2 intermediate states) :
@objc(Full) public static let full: FloatingPanelState = FloatingPanelState(rawValue: "full", order: 1000) /// A panel state indicates the 3/4 of a panel is shown. @objc(LastQuart) public static let lastQuart: FloatingPanelState = FloatingPanelState(rawValue: "lastQuart", order: 750) /// A panel state indicates the half of a panel is shown. @objc(Half) public static let half: FloatingPanelState = FloatingPanelState(rawValue: "half", order: 500) /// A panel state indicates the 1/4 of a panel is shown. @objc(FirstQuart) public static let firstQuart: FloatingPanelState = FloatingPanelState(rawValue: "firstQuart", order: 250) /// A panel state indicates the tip of a panel is shown. @objc(Tip) public static let tip: FloatingPanelState = FloatingPanelState(rawValue: "tip", order: 100)
all good for me
you could open FloatingPanelState to be able to easily add states
Hi, @i-arun-samui. Could you tell me how you use lastQuart
and firstQuart
? Because I think just adding them is not enough to deactivate attractions 🤔
hi, it doesn't deactivate attractions but it add intermediate states which suit my needs. I couldn't achieve the deactivation of attraction without messing up layout. I need initial state to be bottom (tip) with min Y (absoluteInset: 20.0 from bottom edge) and Max Y (top view area)
On iPad I'm thinking to add more intermediates states
class VerticalFloatingPanelLayout: FloatingPanelLayout { let position: FloatingPanelPosition = .bottom let initialState: FloatingPanelState = .tip var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] { return [ .full: FloatingPanelLayoutAnchor(absoluteInset: 0.0, edge: .top, referenceGuide: .safeArea), .lastQuart: FloatingPanelLayoutAnchor(fractionalInset: 0.75, edge: .bottom, referenceGuide: .safeArea), .half: FloatingPanelLayoutAnchor(fractionalInset: 0.5, edge: .bottom, referenceGuide: .safeArea), .firstQuart: FloatingPanelLayoutAnchor(fractionalInset: 0.25, edge: .bottom, referenceGuide: .safeArea), .tip: FloatingPanelLayoutAnchor(absoluteInset: 20.0, edge: .bottom, referenceGuide: .safeArea), ] } }
this line doesn't stop attraction floatingPanel.delegate?.floatingPanelDidEndDragging?(floatingPanel, willAttract: false)
Him @i-arun-samui. I've created PR #438 to create a custom state like . lastQuart
/. firstQuart
as you mentioned.
this line doesn't stop attraction floatingPanel.delegate?.floatingPanelDidEndDragging?(floatingPanel, willAttract: false)
Yes, it does because it's a delegate method. You are able to prevent a panel bounce by using a critical damped spring behavior which can be defined in FloatingPanelBehavior.springDecelerationRate.
Hi, Thank you very much for adding states customization, and clarifying the use of floatingPanel, willAttract: false Regards
Description
Expected behavior
I would like to be able to have to floatingpanel to stop where the user stop dragging, with limits on top and bottom
Actual behavior
the floatingpanel goes to top, half, tip
Steps to reproduce
Code example that reproduces the issue
How do you display panel(s)? floatingPanel = FloatingPanelController() floatingPanel.delegate = self floatingPanel.delegate?.floatingPanelDidEndDragging?(floatingPanel, willAttract: false) floatingPanel.layout = MyFloatingPanelLayout() let storyBoard = UIStoryboard(name: "Main", bundle: nil) let contentVC = storyBoard.instantiateViewController(withIdentifier: "pagingPage") as? Paging floatingPanel.set(contentViewController: contentVC) floatingPanel.addPanel(toParent: self)
class MyFloatingPanelLayout: FloatingPanelLayout { let position: FloatingPanelPosition = .bottom let initialState: FloatingPanelState = .tip var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] { return [ .full: FloatingPanelLayoutAnchor(absoluteInset: 0.0, edge: .top, referenceGuide: .safeArea), .half: FloatingPanelLayoutAnchor(fractionalInset: 0.5, edge: .bottom, referenceGuide: .safeArea), .tip: FloatingPanelLayoutAnchor(absoluteInset: 20.0, edge: .bottom, referenceGuide: .safeArea), ] } }
How many panels do you displays? 1
Environment
iphone ipad MacOS catalyst Library version 2.1.0 Installation method CocoaPods
iOS version(s) ios 14
Xcode version 12.2