Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions JZCalendarWeekView/JZBaseWeekView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ open class JZBaseWeekView: UIView {
}
public var numOfDays: Int!
public var scrollType: JZScrollType!
public var scrollWithVelocity: Bool = false
public var currentTimelineType: JZCurrentTimelineType! {
didSet {
let viewClass = currentTimelineType == .section ? JZCurrentTimelineSection.self : JZCurrentTimelinePage.self
Expand Down Expand Up @@ -562,8 +563,13 @@ extension JZBaseWeekView: UICollectionViewDelegate, UICollectionViewDelegateFlow
var shouldScrollToPage: Int

if isVelocitySatisfied {
// If velocity is satisfied, then scroll to next page or current page(currentSection calculated by floor Int)
shouldScrollToPage = currentPage + (velocity.x > 0 ? 1 : 0)
if scrollWithVelocity {
// If velocity is satisfied, then scroll to the nearest page accounting for velocity
shouldScrollToPage = currentPage + Int(round(velocity.x))
} else {
// If velocity is satisfied, then scroll to next page or current page(currentSection calculated by floor Int)
shouldScrollToPage = currentPage + (velocity.x > 0 ? 1 : 0)
}
} else {
// If velocity unsatisfied, then using half distance(round) to check whether scroll to next or current
let scrollDistanceX = currentContentOffset.x - CGFloat(currentPage) * pageWidth
Expand Down