Reload scrolls to top
(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
can you reload with an anchor date? CMD + Click in the scroll function. it is a big function with many options.
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?
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 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.