I need to change part merchandise peak and middle it. However once I attempting to alter peak I am unable to change Y
place in my part. I need to do that:
However I’ve this outcome:
code:
func carouselSection(utilizing part: Part) -> NSCollectionLayoutSection {
///` "Merchandise":
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalHeight(1.0), heightDimension: .fractionalHeight(1.0))
let layoutItem = NSCollectionLayoutItem(layoutSize: itemSize)
layoutItem.contentInsets = NSDirectionalEdgeInsets(high: 10, main: 10, backside: 10, trailing: 10)
///` "Group":
let layoutGroupSize = NSCollectionLayoutSize(widthDimension: .fractionalHeight(1.0), heightDimension: .fractionalHeight(1.0))
let layoutGroup = NSCollectionLayoutGroup.horizontal(layoutSize: layoutGroupSize, subitems: [layoutItem])
///` "Part":
let layoutSection = NSCollectionLayoutSection(group: layoutGroup)
layoutSection.orthogonalScrollingBehavior = .groupPagingCentered
layoutSection.visibleItemsInvalidationHandler = { (gadgets, offset, surroundings) in
gadgets.forEach { merchandise in
let body = merchandise.body
let rect = CGRect(x: offset.x, y: offset.y, width: surroundings.container.contentSize.width, peak: body.peak)
let inter = rect.intersection(body)
let p.c: CGFloat = inter.width / body.width
let scale = 0.8 + (0.2 * p.c)
merchandise.rework = CGAffineTransform(scaleX: 0.98, y: scale)
}
}
return layoutSection
}