SkeletonView icon indicating copy to clipboard operation
SkeletonView copied to clipboard

UICollectionViewCompositionalLayout with orthogonal section breaks skeletonable chain

Open KirilSivokoz opened this issue 2 years ago • 2 comments

Description

Hey!

We are using your awesome lib with UICollectionView for quite a while and everything was just perfect before we decided to migrate to UICollectionViewCompositionalLayout. Specifically, we have one section that has orthogonalScrollingBehavior set to .continuous.

What type of issue is this? (place an x in one of the [ ])

  • [ x ] bug
  • [ ] enhancement (feature request)
  • [ ] question
  • [ ] documentation related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [ x ] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [ x ] I've read and agree to the Code of Conduct.
  • [ x ] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

SkeletonView Environment:

SkeletonView version: 1.29.3 Xcode version: 13.4.1 Swift version: 5

Steps to reproduce:

Please replace this with the steps to reproduce the behavior.

  1. Use UICollectionView with UICollectionViewCompositionalLayout and orthogonalScrollingBehavior.
  2. Set isSkeletonable for collection view and section items to true.

Expected result:

Section with orthogonalScrollingBehavior is skeletoned.

Actual result:

Section with orthogonalScrollingBehavior is not skeletoned.

Attachments:

Investigation results: It seems that for orthogonalScrollingBehavior system wraps items in _UICollectionViewOrthogonalScrollerEmbeddedScrollView, which obviously is not reachable directly and breaks isSkeletonable chain.

Possible workaround: I came up with the workaround, that is probably a bit too hacky for a PR. So I decided to open the issue instead.

extension UIScrollView {
    var isOrthogonalScrollView: Bool {
        let isInCollectionView = superview as? UICollectionView != nil
        return isInCollectionView && subviews.contains { $0.isSkeletonable }
    }

    override public var isSkeletonable: Bool {
        get {
            super.isSkeletonable || isOrthogonalScrollView
        }
        set {
            super.isSkeletonable = newValue
        }
    }
}

KirilSivokoz avatar Jun 13 '22 16:06 KirilSivokoz

Hi @KirilSivokoz Your solution helped me a lot. By the way when your above changes can be merged and released?

jhpassion0621 avatar Dec 07 '22 15:12 jhpassion0621

Confirm. Your solution also works for me

ardavydov avatar Jan 01 '23 16:01 ardavydov