zjfjack / JZCalendarWeekView

Calendar Week & Day View in iOS Swift
MIT License
448 stars 120 forks source link

Error : Fix limited scrolling range when dragging #108

Open aron1127 opened 4 years ago

aron1127 commented 4 years ago

Hi @zjfjack

I've found this error since long ago. I have solved this problem and have been using it. Upload the Pull Request to share with everyone.

Error situation :

  1. Stop in the middle when you drag.
  2. The calendar automatically aligns with the screen.
  3. But if you start dragging again Before views are automatically sorted,
  4. You will be able to drag beyond the limited range. ex) Set limited range to September 10, 2019. If you drag quickly as described, you can drag before September 10.

2 Causes : First, change the scrollDirection variable to nil unconditionally in the scrollViewDidEndDecelating() function. Second, the loadPage() function is called very often.

Change point : Added checkDragRangesInHorizontalScroll() function to JZBaseWeekView.swift. Use the function when setting the scrollDirection variable in the scrollViewDidEndDecelating() function. Also invokes the function before using loadPageSectionScroll(). The checkDragRangesInHorizontalScroll() function compares the difference between the date on the screen that I am viewing and the date that is limited.

I couldn't analyze all the sources. So I don't think this is a good way. But it works! (CAUTION: Not many tests try.)