Skip to content

Commit

Permalink
Fix swipe at bottom issue by temporarily disabling AllDayHeight change
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Zhang committed Dec 12, 2018
1 parent 026daf6 commit dc57db0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Example/JZCalendarWeekViewExample/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.5.5</string>
<string>0.5.6</string>
<key>CFBundleVersion</key>
<string>18110801</string>
<string>18121201</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
2 changes: 1 addition & 1 deletion JZCalendarWeekView.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "JZCalendarWeekView"
s.version = "0.5.5"
s.version = "0.5.6"
s.summary = "Calendar Week & Day View in iOS Swift"
s.homepage = "https://github.com/zjfjack/JZCalendarWeekView"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
2 changes: 1 addition & 1 deletion JZCalendarWeekView/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.5.5</string>
<string>0.5.6</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
14 changes: 12 additions & 2 deletions JZCalendarWeekView/JZBaseWeekView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ open class JZBaseWeekView: UIView {
}

open func updateAllDayBar(isScrolling: Bool) {
guard isAllDaySupported && !isScrolling else { return }
guard isAllDaySupported else { return }
var maxEventsCount: Int = 0
getDatesInCurrentPage(isScrolling: isScrolling).forEach {
let count = allDayEventsBySection[$0]?.count ?? 0
Expand All @@ -196,7 +196,10 @@ open class JZBaseWeekView: UIView {
}
let newAllDayHeader = flowLayout.defaultAllDayOneLineHeight * CGFloat(min(maxEventsCount, 2))
if newAllDayHeader != flowLayout.allDayHeaderHeight {
flowLayout.allDayHeaderHeight = newAllDayHeader
// Check whether we need update the allDayHeaderHeight
if !isScrolling || !willEffectContentSize(difference: flowLayout.allDayHeaderHeight - newAllDayHeader) {
flowLayout.allDayHeaderHeight = newAllDayHeader
}
}
}

Expand Down Expand Up @@ -224,6 +227,13 @@ open class JZBaseWeekView: UIView {
collectionView.reloadData()
}

/// Notice: A temporary solution to fix the scroll from bottom issue when isScrolling
/// The issue is because the decreased height value will cause the system to change the collectionView contentOffset, but the affected contentOffset will
/// greater than the contentSize height, and the view will show some abnormal updates, this value will be used with isScrolling to check whether the in scroling change will be applied
private func willEffectContentSize(difference: CGFloat) -> Bool {
return collectionView.contentOffset.y + difference + collectionView.bounds.height > collectionView.contentSize.height
}

/// Fix collectionView scroll from bottom (contentsize height decreased) wrong offset issue
private func getYOffset() -> CGFloat {
guard isAllDaySupported else { return collectionView.contentOffset.y }
Expand Down

0 comments on commit dc57db0

Please sign in to comment.