preferredScrollPosition option in scrollToDate function is not being applied
Version Number: 8.0.1
Description
I've tried to use the option preferredScrollPosition on scrollToDate function, regardless of the parameter I send, it does nothing different.
I've checked the code, and it seems the parameter is not sent to the function targetPointForItemAt when calculating the point. I've tried to add it myself in the call of the function, but nothing new happened.
I've checked then targetPointForItemAt function, and it doesn't seem to use the parameter preferredScrollPosition in its calculations.
Maybe I'm missing something... If this is not yet implemented, please let me know.
Steps To Reproduce
Call scrollToDate with parameter preferredScrollPosition different to nil or top.
Expected Behavior
When changing preferredScrollPosition to something different to nil or top, the scroll position of the scrollToDate should change.
Additional Context
Sorry for getting to this so late.
This needs some more thought. I am thinking of removing the preferred position.
I do not know of a good use case for this with this library. If you have a screen shot of how you want this property to be applied, then can you show me here? You can drag the screenshot in the chat box.
No worries!
In the end, I decided to implement another interaction that made more sense for the context. So I won't need the option anymore. I'm trying to recall what exactly was the use case, but I don't remember, sorry.
Either way, for me, not having the option is not a big deal. So if you decide to remove the preferred position is ok with me. The confusion started when I saw the parameter on the function.
Thanks for your response and this great library!
Thanks. I'll update and remove that function soon.
@patchthecode
I have a use case.

This is a UIToolbar housing an instance of the JTAppleCalendarView limited to a single row. The date range is only 7 days and I hide the cells for any days outside of this range. I have disabled scrolling and had imagined that a call to scrollToDate with preferredScrollPosition: .right would position the view as desired.
What happens is that today's cell is seen on the left, the rest remains blank.
@patchthecode
I see you respond quickly :-)
I came up with a solution. In my viewDidLoad, I scrollToDate, and from within its completionHandler, I selectDates and then scrollToItem. It would of course be nice if scrollToDate did this for me, without prior selection, if you think this is a reasonable use case to support.
self.toolbar.calendarView.scrollToDate(self.viewModel.todaysDate
, triggerScrollToDateDelegate: false
, animateScroll: false
, preferredScrollPosition: .right
, extraAddedOffset: 0) { [weak self] in
guard let self = self else { return }
self.toolbar.calendarView.selectDates([self.viewModel.todaysDate]
, triggerSelectionDelegate: false)
if let today = self.toolbar.calendarView.indexPathsForSelectedItems?.first {
self.toolbar.calendarView.scrollToItem(at: today, at: .right, animated: false)
}
}
I sorta swamped with projects right now, so I'll take a look over the weekend along with some other PRs.
Thanks for the code of possible solutions. This helps me a lot.