Skip to content

Commit

Permalink
small fix regarding scrollToIndexPath (jessesquires#1642) close jesse…
Browse files Browse the repository at this point in the history
  • Loading branch information
IceFloe authored and Edward Sammut Alessi committed Aug 22, 2016
1 parent ae8cdcc commit 5ccf8d0
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,10 @@ - (void)scrollToIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated
// if last message is too long, use scroll position bottom for better appearance, else use top
// possibly a UIKit bug, see #480 on GitHub
CGSize cellSize = [self.collectionView.collectionViewLayout sizeForItemAtIndexPath:indexPath];
CGFloat maxHeightForVisibleMessage = CGRectGetHeight(self.collectionView.bounds) - self.collectionView.contentInset.top - CGRectGetHeight(self.inputToolbar.bounds);
CGFloat maxHeightForVisibleMessage = CGRectGetHeight(self.collectionView.bounds) -
self.collectionView.contentInset.top -
self.collectionView.contentInset.bottom -
CGRectGetHeight(self.inputToolbar.bounds);
UICollectionViewScrollPosition scrollPosition = (cellSize.height > maxHeightForVisibleMessage) ? UICollectionViewScrollPositionBottom : UICollectionViewScrollPositionTop;

[self.collectionView scrollToItemAtIndexPath:indexPath
Expand Down

0 comments on commit 5ccf8d0

Please sign in to comment.