@@ -492,6 +492,25 @@ export class CollectionView extends CollectionViewBase {
492492 indexes . forEach ( ( index ) => sizes . replaceObjectAtIndexWithObject ( index , NSValue . valueWithCGSize ( CGSizeZero ) ) ) ;
493493 }
494494 }
495+ public layoutAttributesForElementsInRect ( attributesArray : NSArray < UICollectionViewLayoutAttributes > , rect : CGRect ) {
496+ if ( this . itemOverlap ) {
497+ let currentDeltaX = 0 ;
498+ let currentDeltaY = 0 ;
499+ for ( let index = 0 ; index < attributesArray . count ; index ++ ) {
500+ const attributes = attributesArray . objectAtIndex ( index ) ;
501+ if ( attributes . representedElementCategory === UICollectionElementCategory . Cell ) {
502+ const row = attributes . indexPath . row ;
503+ if ( this . itemOverlap ) {
504+ attributes . zIndex = row ;
505+ }
506+ const itemOverlap = this . itemOverlap ( this . getItemAtIndex ( row ) , row ) ;
507+ currentDeltaX += Utils . layout . toDeviceIndependentPixels ( Length . toDevicePixels ( itemOverlap [ 1 ] , 0 ) + Length . toDevicePixels ( itemOverlap [ 3 ] , 0 ) ) ;
508+ currentDeltaY += Utils . layout . toDeviceIndependentPixels ( Length . toDevicePixels ( itemOverlap [ 0 ] , 0 ) + Length . toDevicePixels ( itemOverlap [ 2 ] , 0 ) ) ;
509+ attributes . center = CGPointMake ( attributes . center . x + currentDeltaX , attributes . center . y + currentDeltaY ) ;
510+ }
511+ }
512+ }
513+ }
495514
496515 public onSourceCollectionChanged ( event : ChangedData < any > ) {
497516 const view = this . nativeViewProtected ;
@@ -1237,22 +1256,7 @@ class UICollectionViewFlowLayoutImpl extends UICollectionViewFlowLayout {
12371256 layoutAttributesForElementsInRect ( rect : CGRect ) {
12381257 const attributesArray = super . layoutAttributesForElementsInRect ( rect ) ;
12391258 const owner = this . _owner ?. get ( ) ;
1240- if ( owner ?. itemOverlap ) {
1241- for ( let index = 0 ; index < attributesArray . count ; index ++ ) {
1242- const attributes = attributesArray . objectAtIndex ( index ) ;
1243- if ( attributes . representedElementCategory === UICollectionElementCategory . Cell ) {
1244- const row = attributes . indexPath . row ;
1245- if ( owner . itemOverlap ) {
1246- attributes . zIndex = row ;
1247- }
1248- const itemOverlap = owner . itemOverlap ( owner . getItemAtIndex ( row ) , row ) ;
1249- const xPosition = attributes . center . x + Utils . layout . toDeviceIndependentPixels ( Length . toDevicePixels ( itemOverlap [ 1 ] , 0 ) + Length . toDevicePixels ( itemOverlap [ 2 ] , 0 ) ) * row ;
1250- const yPosition = attributes . center . y + Utils . layout . toDeviceIndependentPixels ( Length . toDevicePixels ( itemOverlap [ 0 ] , 0 ) + Length . toDevicePixels ( itemOverlap [ 2 ] , 0 ) ) * row ;
1251- attributes . center = CGPointMake ( xPosition , yPosition ) ;
1252- }
1253- }
1254- }
1255-
1259+ owner ?. layoutAttributesForElementsInRect ( attributesArray , rect ) ;
12561260 return attributesArray ;
12571261 }
12581262 shouldInvalidateLayoutForBoundsChange ( newBounds : CGRect ) {
0 commit comments