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: Cell rendering #54

Closed
btxsqdr opened this issue Apr 5, 2019 · 6 comments
Closed

Bug: Cell rendering #54

btxsqdr opened this issue Apr 5, 2019 · 6 comments

Comments

@btxsqdr
Copy link

btxsqdr commented Apr 5, 2019

Hey Jeff

I've found an issue that might be important. Could you have a look at it? Thank you. @zjfjack

These 3 events are from the same day, yet the 3rd appears on the next day:

cal1

Here's how to reproduce:

For simplification, use your example code and alter AllDayViewModel like so

class AllDayViewModel: NSObject {

    private let firstDate = Date()
    private let secondDate = Date().add(component: .minute, value: 22)
    private let thirdDate = Date().add(component: .minute, value: 27)

    lazy var events = [
        AllDayEvent(id: "0", title: "One", startDate: firstDate, endDate: firstDate.add(component: .minute, value: 30), location: "Melbourne", isAllDay: false),

        AllDayEvent(id: "1", title: "Two", startDate: secondDate, endDate: secondDate.add(component: .minute, value: 30), location: "Sydney", isAllDay: false),

        AllDayEvent(id: "2", title: "Three", startDate: thirdDate, endDate: thirdDate.add(component: .minute, value: 30), location: "Tasmania", isAllDay: false)
    ]

    lazy var eventsByDate = JZWeekViewHelper.getIntraEventsByDate(originalEvents: events)

    var currentSelectedData: OptionsSelectedData!

}

It means that 3 events that are very close should be rendered on the same day.

Thank you very much! :)

@btxsqdr
Copy link
Author

btxsqdr commented Apr 16, 2019

@zjfjack May I ask for a status update? Are you working on it or shall I try to provide a pull request with a hopefully reasonable solution?

@zjfjack
Copy link
Owner

zjfjack commented Apr 16, 2019 via email

@btxsqdr
Copy link
Author

btxsqdr commented Apr 23, 2019

Hey @zjfjack. Could you either give me branch and pull request access, or adjust this code line yourself?

JZWeekViewFlowLayout, line 541

From
for currentY in stride(from: minY, to: maxY, by: 1) {

To
for currentY in stride(from: minY, to: maxY, by: 0.1) {

Because if minY/maxY diff is < 1, stride by 1 will skip some items if too close, therefore 0.1. It is a division issue, apparently.

@btxsqdr
Copy link
Author

btxsqdr commented Apr 24, 2019

@zjfjack see pr #65

@zjfjack
Copy link
Owner

zjfjack commented Apr 27, 2019

Hi @btxsqdr

Thanks for your help, I finally have some time to look into this issue.

Your solution can definitely solve this issue, but I am thinking about efficiency. The original solution is not efficient already. If you change it to 0.1, then it will become worse.

Then, I find a better solution which I will show it here with the algorithm link. Maximum number of overlapping intervals

I will finish the solution in Swift and let you know soon.

Thanks

@zjfjack
Copy link
Owner

zjfjack commented Apr 28, 2019

Pushed new commit, if you have any other questions, let me know. Thanks

@zjfjack zjfjack closed this as completed Apr 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants