@@ -363,31 +363,32 @@ - (void)prepareForCollectionViewUpdates:(NSArray *)updateItems
363
363
{
364
364
[super prepareForCollectionViewUpdates: updateItems];
365
365
366
- if (self.springinessEnabled ) {
367
- [updateItems enumerateObjectsUsingBlock: ^(UICollectionViewUpdateItem *updateItem, NSUInteger index, BOOL *stop) {
368
- if (updateItem.updateAction == UICollectionUpdateActionInsert) {
369
-
370
- if ([self .dynamicAnimator layoutAttributesForCellAtIndexPath: updateItem.indexPathAfterUpdate]) {
371
- *stop = YES ;
372
- }
373
-
374
- CGSize size = self.collectionView .bounds .size ;
375
- JSQMessagesCollectionViewLayoutAttributes *attributes = [JSQMessagesCollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath: updateItem.indexPathAfterUpdate];
376
-
377
- if (attributes.representedElementCategory == UICollectionElementCategoryCell) {
378
- [self jsq_configureMessageCellLayoutAttributes: attributes];
379
- }
380
-
381
- attributes.frame = CGRectMake (0 .0f ,
382
- size.height - size.width ,
383
- size.width ,
384
- size.width );
385
-
366
+ [updateItems enumerateObjectsUsingBlock: ^(UICollectionViewUpdateItem *updateItem, NSUInteger index, BOOL *stop) {
367
+ if (updateItem.updateAction == UICollectionUpdateActionInsert) {
368
+
369
+ if (self.springinessEnabled && [self .dynamicAnimator layoutAttributesForCellAtIndexPath: updateItem.indexPathAfterUpdate]) {
370
+ *stop = YES ;
371
+ }
372
+
373
+ CGFloat collectionViewHeight = CGRectGetHeight (self.collectionView .bounds );
374
+
375
+ JSQMessagesCollectionViewLayoutAttributes *attributes = [JSQMessagesCollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath: updateItem.indexPathAfterUpdate];
376
+
377
+ if (attributes.representedElementCategory == UICollectionElementCategoryCell) {
378
+ [self jsq_configureMessageCellLayoutAttributes: attributes];
379
+ }
380
+
381
+ attributes.frame = CGRectMake (0 .0f ,
382
+ collectionViewHeight + CGRectGetHeight (attributes.frame ),
383
+ CGRectGetWidth (attributes.frame ),
384
+ CGRectGetHeight (attributes.frame ));
385
+
386
+ if (self.springinessEnabled ) {
386
387
UIAttachmentBehavior *springBehaviour = [self jsq_springBehaviorWithLayoutAttributesItem: attributes];
387
388
[self .dynamicAnimator addBehavior: springBehaviour];
388
389
}
389
- }];
390
- }
390
+ }
391
+ }];
391
392
}
392
393
393
394
#pragma mark - Message cell layout utilities
0 commit comments