Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Adding multiple card sizes doesn't snap card correctly #73

Open
ankit01217 opened this issue Aug 26, 2020 · 3 comments
Open

[Bug] Adding multiple card sizes doesn't snap card correctly #73

ankit01217 opened this issue Aug 26, 2020 · 3 comments

Comments

@ankit01217
Copy link

Bug Description

Card Swiper doesn't snap card swipe correctly when we provide different sizes for cards using

func sizeForItem(verticalCardSwiperView: VerticalCardSwiperView, index: Int)

To Reproduce

Steps to reproduce the behavior: Following steps are for ExampleViewController in project

  1. Update contactsDataSource to add size for each item
    e.g.
private var contactsDemoData: [Contact] = [
        Contact(name: "John Doe", age: 33, size: 500),
        Contact(name: "Chuck Norris", age: 78, size: 500),
        Contact(name: "Bill Gates", age: 62, size: 500),
        Contact(name: "Steve Jobs", age: 56, size: 300),
        Contact(name: "Barack Obama", age: 56, size: 300),
        Contact(name: "Mila Kunis", age: 34, size: 300),
        Contact(name: "Pamela Anderson", age: 50, size: 300),
        Contact(name: "Christina Anguilera", age: 37, size: 300),
        Contact(name: "Ed Sheeran", age: 23, size: 300),
        Contact(name: "Jennifer Lopez", age: 45, size: 300),
        Contact(name: "Nicki Minaj", age: 31, size: 300),
        Contact(name: "Tim Cook", age: 57, size: 300),
        Contact(name: "Satya Nadella", age: 50, size: 300)
    ]
  1. Add custom size for cells using delegate method
func sizeForItem(verticalCardSwiperView: VerticalCardSwiperView, index: Int) -> CGSize {
        let contact = contactsDemoData[index]
        return CGSize(width: self.view.bounds.size.width, height: CGFloat(contact.size))
}
  1. Run project and notice, it takes size as expected, but swipe offset doesn't update based on cell size and snaps to wrong position on swipe up

Expected behavior

  • Swipe offset should consider dynamic cell size and update position accordingly

Video

https://jmp.sh/KbBOXeR

Environment

iOS 13.6 - iPhone 11

@ankit01217
Copy link
Author

Screen Recording 2020-08-25 at 10 37 02 PM

@elfanek
Copy link
Contributor

elfanek commented Sep 4, 2020

@JoniVR any ideas on how to add support for cells with multiple heights?

@JoniVR
Copy link
Owner

JoniVR commented Sep 14, 2020

It's not currently supported as I didn't consider it, feel free to open a Pull request though :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants