Jtapplecalendar: Scroll on real time? [enhancement]

Created on 7 Aug 2017  路  11Comments  路  Source: patchthecode/JTAppleCalendar

  1. Currently using 7.0.6
  2. I am using didScrollToDateSegmentWith to change the header of my calendar but if I keep scrolling, the header function didScrollToDateSegmentWith won't be called until I stop scrolling. I would rather have the option to call this function every time that I scroll to a new month. So the header would update right away with every month I go by and not only with the last month.

All 11 comments

hmm. Ok. in that case try implementing this delegate funciton ->

func scrollDidEndDecelerating(for calendar: JTAppleCalendarView) {
   let visibleDates = calendarView.visibleDates()
   // etc etc
}

closing issue, but let me know if it helped.

This doesn't cut it if you have multiple months where you can keep scrolling but still want to see what month you are in without stopping. Maybe I will send a PR with this feature...

OK sorry. maybe i misunderstood the problem. I thought that delegate function will do it.
Let me double check this now.

I now see what you mean. I not sure i'll be able to get to that upgrade right away. But i'll take a look when i'm free.

OK hey, here is an idea, let me know if this can work for you.

in the cellForItemAt function, cells are configured.
Inside that function you have a parameter called cellState.

Is it possible you can try this?

class MyViewController: UIViewController {
   ...
   ...
   var currentMonthIndex: Int ?
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
   let dataSection = cellState.dateSection()
   if dataSection.month != currentMonthIndex {
      currentMonthIndex = dataSection.month
      let visibleDates = calendarView.visibleDates()
      // etc etc 
   }
   ...
   ...
}

I just tested it, and it works.
I think it should be able to work for you.
Let me know.

closing issue now.
Let me know. And if unsolved, i'll re-open it

I get limited control with this... I want to change my outside header right when the top most visible month header reaches the bottom of my outside header... this is a problem since I can not access the scrollViewDidScroll using the contentOffset...

@JesusAdolfo can you try master branch?
we recently added the scrollViewDidScroll function.

func calendarDidScroll(_ calendar: JTAppleCalendarView)

put this is podfile to try the master branch ->

pod 'JTAppleCalendar', :git => 'https://github.com/patchthecode/JTAppleCalendar.git', :branch => 'master'

Let me know if it worked?

Alright this is is awesome... Haven't tried yet but definitely will once you release as a new version. I extended my own delegate from the existing one to get the contentOffset 馃憤

protocol CustomCalendarDelegate: JTAppleCalendarViewDelegate

When are you releasing a new version with this included?
It would make my code cleaner, no need to extend your protocol

Well, first i have to test it, but you can use that branch till its released. My master branches as stable enough.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leo150 picture leo150  路  3Comments

Kevinw14 picture Kevinw14  路  3Comments

programus picture programus  路  3Comments

dbmrq picture dbmrq  路  5Comments

oddpandadesign picture oddpandadesign  路  5Comments