165 Commits

Author SHA1 Message Date
Shin Yamamoto afff000d8c Allow slight deviation when checking for anchor position.
This change addresses the 2nd issue reported in #633. The previous attempt
in commit b0fd0d4 was intended to fix this, but it has a regression.
This change resolves the issue without introducing any regressions.
2025-04-21 20:18:02 +09:00
Shin Yamamoto dd49fdea5e Revert "Disallow interrupting the panel interaction while bouncing over the most expanded state (#652)"
This reverts commit b0fd0d4427.

This change had a problem normal cases. For example, in Maps example a
panel interaction jumps occurs because of this.
2025-04-21 18:09:24 +09:00
Shin Yamamoto a1f20cedb1 Version 2.8.7 2025-04-05 14:11:55 +09:00
Shin Yamamoto 479cce4546 Reset initialScrollOffset after the attracting animation ends (#659)
* Stop pinning the scroll offset in moving programmatically
* Add 'optional' string interpolation
* Add comments
* Add CoreTests.test_initial_scroll_offset_reset()
* ci: remove macos-12 jobs for the deprecation
* ci: name circleci jobs
2025-03-07 18:57:21 +09:00
Shin Yamamoto b0fd0d4427 Disallow interrupting the panel interaction while bouncing over the most expanded state (#652)
I decided to disallow interrupting panel interactions while bouncing over the most expanded state in order to fix the 2nd issue in #633, https://github.com/scenee/FloatingPanel/issues/633#issuecomment-2324666767.
2024-11-09 13:16:47 +09:00
Shin Yamamoto b6e8928b1a Version 2.8.6 2024-09-07 10:12:44 +09:00
Shin Yamamoto 3a3d53424c Fix doc comments' errors (#644)
* Fix doc comment errors in ObjC APIs
* Improve doc comments in LayoutAnchoring.swift
2024-09-06 13:49:56 +09:00
Shin Yamamoto 71f419a3cd Version 2.8.5 2024-08-05 22:07:48 +09:00
Ivan Levin 0e27410460 Replace fatal errors in transitionDuration delegate methods (#642)
This PR modifies the transitionDuration(using:) method in FloatingPanelController to return 0.0 instead of calling fatalError when the FloatingPanelController instance is not found. This change is crucial for several reasons:

1. Avoiding Crashes in Production: Using fatalError in production can lead to unexpected crashes, which are detrimental to user experience. It's safer to return a default value like 0.0 and handle the scenario gracefully.

2. Improved Stability: By returning 0.0, the application can continue running, allowing for better stability and user satisfaction. This approach also aligns with the principle of fail-safety, where the system continues operating under error conditions.

3. Real-World Case: In our large-scale project, we encountered a crash at this specific point due to the fatalError. Given the size and complexity of our application, it has been challenging to pinpoint the exact cause. Switching to a return value of 0.0 would significantly help us mitigate the issue and maintain app stability while we investigate further.

4. Maintainability: Returning a default value makes the codebase more maintainable and easier to debug, as it avoids abrupt termination and allows for logging or other error handling mechanisms.
2024-08-05 22:06:43 +09:00
Shin Yamamoto 29185a47bd Version 2.8.4 2024-07-06 15:59:52 +09:00
Shin Yamamoto 6821b26706 Fix an inappropriate condition to determine scrolling content or not (#633)
Removed the `pre > .zero` condition from `FloatingPanelLayoutAnchor` as it was not appropriate for zero or negative `absoluteInset` values. 

Added documentation for `shouldScrollingContentInMoving(from:to:)` to prevent similar mistakes in the future.
2024-07-04 10:08:17 +09:00
Shin Yamamoto 22d46c5260 Version 2.8.3 2024-06-12 09:21:33 +09:00
Will Bishop 466aaf21dd Fix a compilation error in Xcode 16 (#636)
This patch fixed the error at SurfaceView#L63 in Xcode 16 (#635):

> 'CALayerCornerCurve' is only available in application extensions for iOS 13.0 or newer.
2024-06-12 09:19:04 +09:00
Shin Yamamoto 56e71ac580 Fix a broken panel layout with a compositional collection view (#634)
* Fix #628 
* Add a new sample to test UICollectionView using a compositional layout
2024-06-08 16:23:29 +09:00
Shin Yamamoto e473c3c440 Fix the scroll tracking of WKWebView on iOS 17.4 (#630)
* Fix a scroll tracking issue of WKWebView on iOS 17.4
* Add 'Scroll tracking(List CollectionView)' use case in Samples app
2024-05-18 10:29:12 +09:00
Shin Yamamoto 8f2be39bf4 Version 2.8.2 2024-02-18 15:25:08 +09:00
Shin Yamamoto dcb89f58c3 Add CoreTest.test_handleGesture_endWithoutAttraction() 2024-02-17 09:04:09 +09:00
Shin Yamamoto d39c4b54d1 Enable to define and use a subclass object of BackdropView (#617)
* Enable to create a subclass of BackdropView
* Add a custom backdrop sample in the Samples example
2024-02-16 22:07:14 +09:00
Ortwin Gentz, FutureTap 504182ceae Fix scroll locking behavior (#615)
use a separate `scrollLocked` var instead of abusing the scrollView's properties to store the locked state;
fixes an issue where the scroll indicators were no longer visible because lockScrollView() was executed twice before unlockScrollView() was called (due to the user changing `showsVerticalScrollIndicator` mid-animation);
2024-02-16 22:04:10 +09:00
Shin Yamamoto bc1cfe444b Fix a bug state was not changed property after v2.8.1
The state was not changed after moving a panel without attractive
interaction. For example, a panel is moved from half to full and
the scroll content continues to scroll with its deceleration
animation. We can test it on 'Show tracking(TextView)' in Samples app.

dbef6a6 commit causes this issue.
2024-02-03 13:36:36 +09:00
Shin Yamamoto 0e0f773df7 Possible fix for #586 2024-02-03 10:27:21 +09:00
Shin Yamamoto 5b33d3d5ff Version 2.8.1 2023-11-04 21:17:09 +09:00
Shin Yamamoto dbef6a691a Fix an invalid behavior after switching to a new layout object (#611)
* Added a test for the use case, ControllerTests.test_switching_layout()
2023-11-04 13:25:25 +09:00
Shin Yamamoto dd238884bf Version 2.8.0 2023-10-08 14:51:26 +09:00
Shin Yamamoto 046ed3df5b Modify the doc comment of 'floatingPanel(_:shouldAllowToScroll:in:)' 2023-10-08 14:51:26 +09:00
Shin Yamamoto b8f7ff825d Revise the doc comment of shouldProjectMomentum delegate method 2023-10-08 14:51:26 +09:00
Shin Yamamoto 6fb9a9b3a2 Add a new section for the new API 2023-09-20 08:58:02 +09:00
Shin Yamamoto 6c7f529eff Add 'state' parameter into 'floatingPanel(_:shouldAllowToScroll:)'
This is because the `state` argument of `Core.isScrollable(state:)` is
not always equal to `FloatingPanelController.state` property. Therefore,
the API should pass the `state` property of `Core.isScrollable(state:)`.
2023-09-19 09:41:07 +09:00
Shin Yamamoto c414d3a2a6 Fix errors of offset value from a state position
Sometimes an offset value has an error less than 1 pt, for example,
-0.666... 0.333... etc. This is due to `surfaceView.presentationFrame`.
2023-09-13 22:04:18 +09:00
Shin Yamamoto 8eba647d75 Fix a panel not moving when picked up in certain area
On `DebugTableViewController` in the Samples app, the panel does not move
when a finger move up from the menu area to the grabber area.
`scrollViewFrame` is not necessary due to the same condition is already
checked at Core.swift:L578.
2023-09-13 22:04:18 +09:00
Shin Yamamoto c3568067b7 Reverse 'LayoutAdapter.offsetFromMostExpandedAnchor' direction 2023-09-13 22:04:18 +09:00
Shin Yamamoto 72580f089d Fix scroll offset reset when moving in grabber area
In addition, `scrollFrame` conversion is removed because it's not really
necessary.
2023-09-13 22:04:16 +09:00
Shin Yamamoto c508ec892d Return false in shouldScrollViewHandleTouch if initial touch is outside scroll view 2023-09-13 22:03:29 +09:00
Shin Yamamoto ff2d4a48f1 Enable content scrolling in non-expanded states (#455)
The new `floatingPanel(_:shouldAllowToScroll)` delegate method allows the
library user to determine whether the content scrolls or not in certain
state. `Core.isScrollable(state:)` and `LayoutAdpter.offset(from:)` are
added for this feature.
2023-09-13 20:32:48 +09:00
Shin Yamamoto 62364eb6d5 Update the minimum deployment target to 11.0 2023-09-06 21:57:23 +09:00
Shin Yamamoto ce5469a69d Fix a compile error on swift 5.4 or earlier
The error detail is here:

> Extensions.swift:11:18: error: cannot convert value of type 'CGFloat' to
> expected argument type 'Double'
>
>         let v = (self * p).rounded(.towardZero) / p
>                  ^
>                  Double( )
2023-09-03 23:25:50 +09:00
Shin Yamamoto 93c31fd71d Fix CGFloat.rounded(by displayScale) for a floating point error
Where a value is -0.16666666666674246, -0.0 is the rounded value to be
expected. However the current implementation returned -0.3333333333333.
This is because the floating point error. So this patch truncates it.
2023-09-01 22:34:48 +09:00
Shin Yamamoto 461f637818 Add isLooselyLocked flag 2023-09-01 22:34:48 +09:00
Shin Yamamoto 6b3b18b8ed Care left/right positioned panels on the scroll indicator lock/unlock 2023-09-01 22:34:48 +09:00
Shin Yamamoto b5ca468397 Fix the hidden scroll indicator in Maps example
In Maps example, the scroll indicator of the table view doesn't show
even if `UIScrollView.showsVerticalScrollIndicator` is set to `true`.
This is due to the occurrence of two loose scroll locks before the
scroll content is displayed.
2023-09-01 22:34:45 +09:00
Shin Yamamoto 5d382c440f Rename outdated compilation condition name to latest 2023-09-01 21:13:06 +09:00
Shin Yamamoto debeca1fb2 Version 2.7.0 2023-08-21 19:28:57 +09:00
Shin Yamamoto 9da54f9fc1 Call floatingPanelWillRemove when a panel removes from a window 2023-08-20 22:23:41 +09:00
Shin Yamamoto a13d053867 Update the doc comment of floatingPanelDidEndDragging method 2023-08-20 22:23:41 +09:00
Shin Yamamoto eda7201fe8 Remove unnecessary code 2023-08-18 12:09:34 +09:00
Shin Yamamoto a2db94a8c4 Fix invalid scroll offsets after moving between states
Sometimes, the content offset of the tracking scroll view would become
less than the content inset (e.g. when a panel moves from half to full
state displaying content with a top bar similar to 'Show Navigation
Controller' in the Samples app). This resulted in the content getting
fixed in an unintended position.

For this issue, this commit completely changes the scroll offset pinning
logic from one shot pinning by DispatchQueue at Core:L43-L56

That old logic was added when the UIViewPropertyAnimator was used to move
the panel. But now, the custom animator using CADisplayLink allows
fine-grained control of panel movement and then the scroll offset is
able to be pinned during its panel transitions.
2023-08-17 09:02:35 +09:00
Shin Yamamoto 57495cff84 Fix log prints 2023-08-14 22:32:14 +09:00
Shin Yamamoto c365eadf1e Retain scroll view position while moving between states (#587)
Previously, the panel might not consistently keep its scroll content
offset when moving from its most expanded state to another.

Changes made in this commit:

* Keep the content offset of tracking scroll view in the following cases.
  A panel is moved...
  1. Outside of the tracking scroll view.
  2. Inside of a navigation bar/toolbar over the tracking scroll view.

* Stopped the scroll offset reset of the `stopScrollDeceleration` flag
  in the  `panningEnd` method when the panel transitions from its most
  expanded state because there is no issue without the reset.
2023-08-14 22:28:19 +09:00
Shin Yamamoto 6e17ff734a Modify shouldProjectMomentum(_:{proposedTargetPosition => proposedState}:) 2023-08-11 16:45:23 +09:00
Shin Yamamoto 02ed923e7b Replace 'Position' words 2023-08-11 16:45:23 +09:00