Jtapplecalendar: Incorrect method 'scrollToDate()' in JTACMonthView

Created on 23 Oct 2019  路  4Comments  路  Source: patchthecode/JTAppleCalendar

(Required) Version Number: 8.02

Description

If you select one of the last dates in the MonthView, then after call method scrollToDate() calendar scrolls too high and leaves empty space under it. This method works differently in CalendarView.

Steps To Reproduce

You can reproduce it yourself.

  1. Create calendar with MonthView
  2. Setup date range
  3. Select one of the last dates in this range
  4. Call method scrollToDate() and pass selected date

Expected Behavior

The selected date should not be aligned to top leave an empty space under it.

Additional Context

It is worth paying attention to the implementation of this method in the CalendarView. There calculation a valid point to scroll is implemented differently.

I created a demo-project and short video with this bug and will attach it.

Calendar.zip

bug

Most helpful comment

@patchthecode Will the planned fix also pass preferredScrollPosition from the public scrollToDate public method to the internal one? (currently it is being discarded)

All 4 comments

youre using cocoapods.
let me test a quick-fix. If it works i will do a proper official fix later this week.

Go to the file JTACInteractionMonthFunctions.swift
Goto line 550

replace the the code from line 550 till the end of the function, with this code

if scrollingMode == .none {
            self.scrollToItem(at: sectionIndexPath, at: preferredScrollPosition ?? (scrollDirection == .horizontal ? .left : .top), animated: true)
        } else  {
            guard let point = targetPointForItemAt(indexPath: sectionIndexPath) else {
                assert(false, "Could not determine CGPoint. This is an error. contact developer on github. In production, there will not be a crash, but scrolling will not occur")
                return
            }
            scrollTo(point: point,
                     triggerScrollToDateDelegate: triggerScrollToDateDelegate,
                     isAnimationEnabled: animateScroll,
                     extraAddedOffset: extraAddedOffset,
                     completionHandler: completionHandler)
        }

Press SHIFT + CMD + K to clean your project. (Sometimes Xcode caches the old cocoapod build and you need to clean so that XCode can reflect the code change).

Now run your app. Let me know if it works.

Yes, it works. You just need to add a calling the completion handler.

@patchthecode Will the planned fix also pass preferredScrollPosition from the public scrollToDate public method to the internal one? (currently it is being discarded)

Was this page helpful?
0 / 5 - 0 ratings