SkeletonView
SkeletonView copied to clipboard
UICollectionViewCompositionalLayout with orthogonal section breaks skeletonable chain
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.
- Use
UICollectionView
withUICollectionViewCompositionalLayout
andorthogonalScrollingBehavior
. - Set
isSkeletonable
for collection view and section items totrue
.
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
}
}
}
Hi @KirilSivokoz Your solution helped me a lot. By the way when your above changes can be merged and released?
Confirm. Your solution also works for me