-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chatlayout contentOffset bug #83
Comments
@ekazaev And the code below should work as well, can you please check it?
open override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint) -> CGPoint {
if keepContentOffsetAtBottomOnBatchUpdates,
let collectionView {
invalidationActions.formUnion([.shouldInvalidateOnBoundsChange])
let offset = CGPoint(x: proposedContentOffset.x, y: maxPossibleContentOffset.y)
controller.proposedCompensatingOffset = 0
if needsIOS15_1IssueFix {
collectionView.contentOffset = offset
}
return offset
}
return super.targetContentOffset(forProposedContentOffset: proposedContentOffset)
} Additionally, if the above code is correct, please check whether Thank you 😀 |
@SongSeoYoung I dont fully remember all the details. Some code exists there even if it seems dumb just because collection may not reflect the layout logic the way we both think it should. Some code exists also just so it easier to test edgecases. And make easier to comment out something and check how it works without it. Do not forget that in IOS 18 calculation may be different that in ios 12. Most of the code was written aroung ios 14. |
Hello.
I have a question about the
CollectionviewChatLayout
class code.In the
targetContentOffset
function, what is the logic to calculate thenewProposedContentOffset
value if theproposedCompensatingOffset
value is not zero and collectionView is not nil?In the above code, in the logic that uses the value of
minPossibleContentOffset
and the maximum value ofmin(collectionView.contentOffset.y + controller.proposedCompensatingOffset, maxPossibleContentOffset.y)
to calculate the value of y, why is the value of the second argument min?If I proceed with the code
min(collectionView.contentOffset. y + controller.proposedCompensatingOffset, maxPossibleContentOffset.y)
, I get a bug,I changed it to max (see code below) and it seems to work:
max(collectionView.contentOffset.y + controller.proposedCompensatingOffset, maxPossibleContentOffset.y)
.I'm curious as to why you used
min
.As I understand it,
maxPossibleContentOffset
is the maximum scrollable offset in the current collectionView.If
proposedCompenstatingOffset
is non-zero, I guess I should usemaxPossibleContentOffset
to adjust the offset.In most situations, I've never had a problem with the two values below being the same.
But in a special situation, the
maxPossibleContentOffset.y
value was larger, and only when I assigned this value tonewProposedContentOffset
did I see the offset move as well as if I appliedkeepContentOffsetAtBottomOnBatchUpdates
.I would be grateful if you could answer.
Thank you.
*Note: In the example code I tested, I changed the value of
keepContentOffsetAtBottomOnBatchUpdates
to true and didn't modify the other flag values.The text was updated successfully, but these errors were encountered: