aataraxiaa / ScalingCarousel

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

Allow changing the orientation of the carousel #51

Closed GoodSir42 closed 4 years ago

GoodSir42 commented 6 years ago

Hi! I modified your library to allow changes to the orientation of the carousel. Would you be interested in merging this into the main library?

GoodSir42 commented 6 years ago

Glad you like it! I'll make the changes and update my branch with it. The usage is really straightforward, so the doc should be done fast.

GoodSir42 commented 5 years ago

Hi again,

I finally found some time to get the code updated with an example and noticed that I have issues properly determining the center cell like that:

`open var currentCenterCell: UICollectionViewCell? {

    let lowerBound = inset - 20
    let upperBound = inset + 20

    for cell in visibleCells {

        let cellRect = convert(cell.frame, to: nil)

        if (scrollDirection == .horizontal && cellRect.origin.x > lowerBound && cellRect.origin.x < upperBound) ||
            (scrollDirection == .vertical && cellRect.origin.y > lowerBound && cellRect.origin.y < upperBound)
        {
            return cell
        }

    }
    return nil
}`

I don't really understand why the upper and lower bounds are inset +- 20. maybe you can have a look and let me know how to fix this?

aataraxiaa commented 5 years ago

Hi @Eifelschaf, the upper and lower bounds need to take the cell inset into account. The 20 is a number to try to avoid false positives.

What issue are you experiencing?

GoodSir42 commented 5 years ago

I fixed the issues with the spacing everything looks good now.

aataraxiaa commented 4 years ago

Closing as stale