JTAppleCalendar icon indicating copy to clipboard operation
JTAppleCalendar copied to clipboard

Reload scrolls to top

Open TheDragonessOfTheMoon opened this issue 5 years ago • 3 comments

(Required) Version Number: 8.0.3

Description

Hi, After changing my content and reloading the calendar it scrolls up to the top of the calendar. I would like it to stay, is it possible to do that? How would I do that?

Steps To Reproduce

Config: ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 6, calendar: calendar, generateInDates: .forAllMonths, generateOutDates: .tillEndOfRow, firstDayOfWeek: firstDayOfWeek, hasStrictBoundaries: true)

Expected Behavior

After a reload it would be nice if it stayed at the last position.

Additional Context

TheDragonessOfTheMoon avatar Jan 14 '21 09:01 TheDragonessOfTheMoon

can you reload with an anchor date? CMD + Click in the scroll function. it is a big function with many options.

patchthecode avatar Jan 14 '21 23:01 patchthecode

That's what I do today:

let scrollDate: Date? if let selectedDate = calendarView.selectedDates.first { scrollDate = selectedDate } else { scrollDate = calendarView.visibleDates().monthDates.first?.date } calendarView.reloadData(withAnchor: scrollDate)

But I don't always know where the user left. Is it possible to get the date that it is scrolled to?

TheDragonessOfTheMoon avatar Jan 15 '21 14:01 TheDragonessOfTheMoon

In case it helps anyone else, I was able to work around this by using the completionHandler of reloadData(withAnchor: completionHandler) and in that handler I'm calling scrollToDate(_) passing in the current visible date. It is not ideal but it at least preserves the user's location in the calendar.

calendarView.reloadData(withAnchor: calendarView.visibleDates().monthDates.first?.date ?? Date(), completionHandler: {
     calendarView.scrollToDate(calendarView.visibleDates().monthDates.first?.date ?? Date())
})

arvinkx avatar Feb 12 '21 03:02 arvinkx

@arvinkx Well its not a work around.. this is the way to do it 😄.

i mentioned this to the original poster here https://github.com/patchthecode/JTAppleCalendar/issues/1305#issuecomment-760545020

So i guess he fixed it. Closing this.

patchthecode avatar Aug 29 '23 18:08 patchthecode