Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Approach to ASCollectionView interactive percentage based layout transition #1855

@nickvelloff

Description

@nickvelloff

I want to improve performance with my ASCollectionView, interactive percentage based transition driven by pinch gesture.

First approach was to expose a new method relayoutItems in ASCollectionView which just calls [_dataController relayoutAllNodes]; ..

This didn’t (and we knew it wouldn’t) perform very well, but it was a first attempt in allowing a transition between layout classes. It worked, but not smoothly.

Next attempt was in my UICollectionViewTransitionLayout in invalidateLayout get only visibleNodes and apply ASSizeRange with a calculated itemSize based on transitionProgress and call node.measureWithSizeRange(sizeRange).size and set the frame

Again, worked but pretty laggy. So onward to the question:

Would it make sense to explore using the Transition API to size the nodes (presumably visible only) with something like

node.transitionLayoutWithSizeRange(
                sizeRange,
                animated: false,
                shouldMeasureAsync: false,
                measurementCompletion: .None
            )

in invalidateLayout in the same way in UICollectionViewTransitionLayout as above?
In the cell node, set the frame in coordination with this as so:

override func animateLayoutTransition(context: ASContextTransitioning) {
        let size0 = context.constrainedSizeForKey(ASTransitionContextToLayoutKey).max
        self.frame = CGRect(origin: self.frame.origin, size: size0)
        context.completeTransition(true)
    }

Initial tests seem like better performance, but it seems like it is fighting with scroll position, or something else, not sure.

If not, any other ideas to get this to perform a bit better?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions