JTAppleCalendar icon indicating copy to clipboard operation
JTAppleCalendar copied to clipboard

`willScrollToDateSegmentWith` is not called when scrolling back to the first page (page 0)

Open mindgrub-rkoch opened this issue 6 years ago • 4 comments

(Required) Version Number: 8.0.2

Description

When implementing the willScrollToDateSegmentWith delegate function, it is not called when scrolling back to the first page.

Steps To Reproduce

  1. Create a calendar with scrolling mode of .stopAtEachSection
  2. implement the willScrollToDateSegmentWith delegate function
  3. Scroll to page 1
  4. Scroll back to page 0

Notice, willScrollToDateSegmentWith is not called.

Expected Behavior

willScrollToDateSegmentWith should be called when scrolling back to page 0.

mindgrub-rkoch avatar Oct 21 '19 18:10 mindgrub-rkoch

will look into this

patchthecode avatar Oct 23 '19 02:10 patchthecode

I have this same issue

mrayls avatar Jan 07 '20 21:01 mrayls

I have the same issue. still now. Anyone ?

luminkhant avatar Dec 17 '20 08:12 luminkhant

I have the same issue and the problem seems to be caused by: Here you computed theCurrentContentOffset with scrollView's contentOffset, and let's say it gives 1450 when scrolling to the last segment. Then maxContentOffset is computed using scrollView.contentSize.width - scrollView.frame.width, which, might also be 1450. And here we return because we thought the user has scrolled beyond the border, even if he/she didn't.

Normally, a user might not scroll to exactly the end of the segment, 1450 in our example. But when a scroll is interrupted by view popping and pushing, UIKit manually scrolls the view to targetContentOffset, which might gives us a case where:

  • User scrolled to 1400, which is fine. Then he/she pressed a button to navigate to another view
  • UIKit would call scrollViewWillEndDragging in this case and with a scrollView whose contentOffset is 1450

Instead I think you should just remove the two = signs here

if theCurrentContentOffset >= maxContentOffset { setTargetContentOffset(maxContentOffset) ; return }
if theCurrentContentOffset <= 0 { setTargetContentOffset(0); return }

Or maybe we should just remove the two returns here? Even if a user scrolls beyond the border, we should still get a willScrollToDateSegmentWith call back. But that's just my thoughts.

So the user can still get a willScrollToDateSegmentWith call back when he navigates around and UIKit decides he scrolled to another location.

dendenxu avatar Feb 05 '21 05:02 dendenxu