invalidationContext(forInteractivelyMovingItems:withTargetPosition:previousIndexPaths:previousPosition:)
Retrieves a context object that identifies the items that are being interactively moved in the layout.
Declaration
func invalidationContext(forInteractivelyMovingItems targetIndexPaths: [IndexPath], withTargetPosition targetPosition: CGPoint, previousIndexPaths: [IndexPath], previousPosition: CGPoint) -> UICollectionViewLayoutInvalidationContextParameters
- targetIndexPaths:
The current locations of the items being moved.
- targetPosition:
The point in the collection view’s coordinate system that is the potential drop point for the items.
- previousIndexPaths:
The previous locations of the items being moved.
- previousPosition:
The previous point in the collection view’s coordinate system. This is the point that was previously used to determine the drop point for the items.
Return Value
An invalidation context that includes information about what changes need to be made to the layout.
Discussion
The layout object uses this method to retrieve invalidation contexts when an interactive move of one or more items is in progress. The default implementation creates an instance of the class provided by the invalidationContextClass class method, fills it with the provided information, and returns it. If you want to use a custom invalidation context object with your layout, always override that method and return your custom class.
Subclasses can override this method and use it to perform additional configuration of the invalidation context before returning it. In your custom implementation, call super so that the parent class can perform the basic configuration of the object.
See Also
Invalidating the layout
invalidateLayout()invalidateLayout(with:)invalidationContextClassshouldInvalidateLayout(forBoundsChange:)invalidationContext(forBoundsChange:)shouldInvalidateLayout(forPreferredLayoutAttributes:withOriginalAttributes:)invalidationContext(forPreferredLayoutAttributes:withOriginalAttributes:)invalidationContextForEndingInteractiveMovementOfItems(toFinalIndexPaths:previousIndexPaths:movementCancelled:)