@@ -67,9 +67,12 @@ public final class ChatLayout: UICollectionViewLayout {
67
67
68
68
/// Represent the rectangle where all the items are aligned.
69
69
public var layoutFrame : CGRect {
70
+ guard let collectionView = collectionView else {
71
+ return . zero
72
+ }
70
73
return CGRect ( x: adjustedContentInset. left + settings. additionalInsets. left,
71
74
y: adjustedContentInset. top + settings. additionalInsets. top,
72
- width: visibleBounds . width - settings. additionalInsets. left - settings. additionalInsets. right - adjustedContentInset. left - adjustedContentInset. right,
75
+ width: collectionView . bounds . width - settings. additionalInsets. left - settings. additionalInsets. right - adjustedContentInset. left - adjustedContentInset. right,
73
76
height: controller. contentHeight ( at: state) - settings. additionalInsets. top - settings. additionalInsets. bottom - adjustedContentInset. top - adjustedContentInset. bottom)
74
77
}
75
78
@@ -678,7 +681,7 @@ public final class ChatLayout: UICollectionViewLayout {
678
681
679
682
let kind = ItemKind ( elementKind)
680
683
if state == . afterUpdate {
681
- if controller. insertedIndexes . contains ( elementIndexPath ) || controller . insertedSectionsIndexes. contains ( elementIndexPath. section) {
684
+ if controller. insertedSectionsIndexes. contains ( elementIndexPath. section) {
682
685
attributes = controller. itemAttributes ( for: elementIndexPath, kind: kind, at: . afterUpdate)
683
686
attributes? . alpha = 0
684
687
attributesForPendingAnimations [ kind] ? [ elementIndexPath] = attributes
@@ -710,7 +713,7 @@ public final class ChatLayout: UICollectionViewLayout {
710
713
711
714
let kind = ItemKind ( elementKind)
712
715
if state == . afterUpdate {
713
- if controller. deletedIndexes . contains ( elementIndexPath ) || controller . deletedSectionsIndexes. contains ( elementIndexPath. section) {
716
+ if controller. deletedSectionsIndexes. contains ( elementIndexPath. section) {
714
717
attributes = controller. itemAttributes ( for: elementIndexPath, kind: kind, at: . beforeUpdate) ?? ChatLayoutAttributes ( forSupplementaryViewOfKind: elementKind, with: elementIndexPath)
715
718
attributes? . alpha = 0
716
719
} else if let itemIdentifier = controller. itemIdentifier ( for: elementIndexPath, kind: kind, at: . beforeUpdate) ,
0 commit comments