aataraxiaa / ScalingCarousel

A super simple carousel view with scaling transitions written in Swift
MIT License
756 stars 98 forks source link

Vertical scroll does not work #78

Closed AndrexOfficial closed 4 years ago

AndrexOfficial commented 4 years ago

I'm trying to use this component in order to get a vertical scroll but If I set it on the FlowLayout it always scrolls horizontally. Any ideas?

aataraxiaa commented 4 years ago

I've never used it with a vertical layout, but likely that the prepare method of ScalingCarouselLayout is overriding your setting with the line:

scrollDirection = .horizontal
AndrexOfficial commented 4 years ago

Exactly, I set scrollDirection = .vertical and then in the layout swift file I did something like this:

override open func prepare() {

        guard let collectionViewSize = collectionView?.frame.size else { return }

        if isHorizontalScroll {
            itemSize = collectionViewSize
            itemSize.width = itemSize.width - (inset * 2)

            // Set scrollDirection and paging
            scrollDirection = .horizontal
            collectionView?.isPagingEnabled = true

            sectionInset = UIEdgeInsets(top: 0.0, left: inset, bottom: 0.0, right: inset)

        } else {
            itemSize = collectionViewSize
            itemSize.height = itemSize.height - (inset * 2)

            // Set scrollDirection and paging
            scrollDirection = .vertical
            collectionView?.isPagingEnabled = true

            sectionInset = UIEdgeInsets(top: inset, left: 0.0, bottom: inset, right: 0.0)
        }

        minimumLineSpacing = 0.0
        minimumInteritemSpacing = 0.0

        footerReferenceSize = CGSize.zero
        headerReferenceSize = CGSize.zero
    }

I works but partially, I'm still having issue with the cells spacing and scaling, now it seems just a vertical scroller like a tableview.

Do you have any suggestions?

aataraxiaa commented 4 years ago

It might be due to the "invisible" scroll view which is added in the ScalingCarouselView, so maybe look into that, but I'm not certain.

I only ever really intended to use ScalingCarousel for horizontal scrolling, so I'm not sure if it's possible to get it working vertically. However, it sounds like you are close, so if you do get it working, we could consider adding that functionality to the library, which would be awesome.

AndrexOfficial commented 4 years ago

Yeah, I'm gonna test and fix something, hope to get it work very soon. Thanks mate

aataraxiaa commented 4 years ago

Implemented by @tejuamirthi, released in v3.1.0

Closing this issue