|
5 | 5 | CoreTypes, |
6 | 6 | EventData, |
7 | 7 | KeyedTemplate, |
| 8 | + Length, |
8 | 9 | Observable, |
9 | 10 | Property, |
10 | 11 | ProxyViewContainer, |
@@ -988,12 +989,10 @@ export class CollectionView extends CollectionViewBase { |
988 | 989 | } |
989 | 990 | if (this.itemOverlap) { |
990 | 991 | // should we force clipsToBounds? not doing so allows more complex layouts like overlapping |
991 | | - cell.clipsToBounds = false; |
992 | 992 | // we set zPosition to allow overlap. Should we make it an option? |
993 | 993 | cell.layer.zPosition = indexPath.row; |
994 | | - } else { |
995 | | - cell.clipsToBounds = true; |
996 | 994 | } |
| 995 | + cell.clipsToBounds = true; |
997 | 996 | const firstRender = !cell.view; |
998 | 997 | if (Trace.isEnabled()) { |
999 | 998 | CLog(CLogTypes.log, 'collectionViewCellForItemAtIndexPath', indexPath.row, templateType, !!cell.view, cell); |
@@ -1197,6 +1196,32 @@ class UICollectionViewFlowLayoutImpl extends UICollectionViewFlowLayout { |
1197 | 1196 | } |
1198 | 1197 | return super.invalidationContextForInteractivelyMovingItemsWithTargetPositionPreviousIndexPathsPreviousPosition(targetIndexPaths, targetPosition, previousIndexPaths, previousPosition); |
1199 | 1198 | } |
| 1199 | + layoutAttributesForElementsInRect(rect: CGRect) { |
| 1200 | + const attributesArray = super.layoutAttributesForElementsInRect(rect); |
| 1201 | + const owner = this._owner?.get(); |
| 1202 | + if (owner?.itemOverlap) { |
| 1203 | + const itemOverlap = owner.itemOverlap; |
| 1204 | + for (let index = 0; index < attributesArray.count; index++) { |
| 1205 | + const attributes = attributesArray.objectAtIndex(index); |
| 1206 | + if (attributes.representedElementCategory === UICollectionElementCategory.Cell) { |
| 1207 | + const xPosition = |
| 1208 | + attributes.center.x + Utils.layout.toDeviceIndependentPixels(Length.toDevicePixels(itemOverlap[1], 0) + Length.toDevicePixels(itemOverlap[2], 0)) * attributes.indexPath.row; |
| 1209 | + const yPosition = |
| 1210 | + attributes.center.y + Utils.layout.toDeviceIndependentPixels(Length.toDevicePixels(itemOverlap[0], 0) + Length.toDevicePixels(itemOverlap[2], 0)) * attributes.indexPath.row; |
| 1211 | + attributes.center = CGPointMake(xPosition, yPosition); |
| 1212 | + } |
| 1213 | + } |
| 1214 | + } |
| 1215 | + |
| 1216 | + return attributesArray; |
| 1217 | + } |
| 1218 | + shouldInvalidateLayoutForBoundsChange(newBounds: CGRect) { |
| 1219 | + const owner = this._owner?.get(); |
| 1220 | + if (owner?.itemOverlap) { |
| 1221 | + return true; |
| 1222 | + } |
| 1223 | + return super.shouldInvalidateLayoutForBoundsChange(newBounds); |
| 1224 | + } |
1200 | 1225 | } |
1201 | 1226 | @NativeClass |
1202 | 1227 | class CollectionViewDataSource extends NSObject implements UICollectionViewDataSource { |
|
0 commit comments