   }
 
   public var timelineScrollOffset: CGPoint {
-    // Any view is fine as they are all synchronized
-    return timelinePager.reusableViews.first?.contentOffset ?? CGPoint()
+    return timelinePagerView.timelineScrollOffset
   }
 
   static let headerVisibleHeight: CGFloat = 88

  public func updateStyle(_ newStyle: CalendarStyle) {
    style = newStyle.copy() as! CalendarStyle
    dayHeaderView.updateStyle(style.header)
    timelinePager.reusableViews.forEach{ timelineContainer in
      timelineContainer.timeline.updateStyle(style.timeline)
      timelineContainer.backgroundColor = style.timeline.backgroundColor
    }
  }

  public func changeCurrentDate(to newDate: Date) {
    let newDate = newDate.dateOnly()
    if newDate.isEarlier(than: currentDate) {
      var timelineDate = newDate
      for (index, timelineContainer) in timelinePager.reusableViews.enumerated() {
        timelineContainer.timeline.date = timelineDate
        timelineDate = timelineDate.add(TimeChunk(seconds: 0, minutes: 0, hours: 0, days: 1, weeks: 0, months: 0, years: 0))
        if index == 0 {
          updateTimeline(timelineContainer.timeline)
        }
      }
      timelinePager.scrollBackward()
    } else if newDate.isLater(than: currentDate) {
      var timelineDate = newDate
      for (index, timelineContainer) in timelinePager.reusableViews.reversed().enumerated() {
        timelineContainer.timeline.date = timelineDate
        timelineDate = timelineDate.subtract(TimeChunk(seconds: 0, minutes: 0, hours: 0, days: 1, weeks: 0, months: 0, years: 0))
        if index == 0 {
          updateTimeline(timelineContainer.timeline)
        }
      }
      timelinePager.scrollForward()
    }
    currentDate = newDate
  }

  public func timelinePanGestureRequire(toFail gesture: UIGestureRecognizer) {
    for timelineContainer in timelinePager.reusableViews {
      timelineContainer.panGestureRecognizer.require(toFail: gesture)
    }
  }
  
  public func scrollTo(hour24: Float) {
    // Any view is fine as they are all synchronized
    timelinePager.reusableViews.first?.scrollTo(hour24: hour24)
  }

  func configureTimelinePager() {
    var verticalScrollViews = [TimelineContainer]()
    for i in -1...1 {
      let timeline = TimelineView(frame: bounds)
      timeline.delegate = self
      timeline.eventViewDelegate = self
      timeline.frame.size.height = timeline.fullHeight
      timeline.date = currentDate.add(TimeChunk(seconds: 0,
                                                minutes: 0,
                                                hours: 0,
                                                days: i,
                                                weeks: 0,
                                                months: 0,
                                                years: 0))

      let verticalScrollView = TimelineContainer()
      verticalScrollView.timeline = timeline
      verticalScrollView.addSubview(timeline)
      verticalScrollView.contentSize = timeline.frame.size

      timelinePager.addSubview(verticalScrollView)
      timelinePager.reusableViews.append(verticalScrollView)
      verticalScrollViews.append(verticalScrollView)
    }
    timelineSynchronizer = ScrollSynchronizer(views: verticalScrollViews)
    addSubview(timelinePager)

    timelinePager.viewDelegate = self
  }

  public func reloadData() {
    timelinePager.reusableViews.forEach{self.updateTimeline($0.timeline)}
  }

  override public func layoutSubviews() {
    super.layoutSubviews()

    let contentWidth = CGFloat(timelinePager.reusableViews.count) * bounds.width
    let size = CGSize(width: contentWidth, height: 50)
    timelinePager.contentSize = size
    timelinePager.contentOffset = CGPoint(x: bounds.width, y: 0)

    dayHeaderView.anchorAndFillEdge(.top, xPad: 0, yPad: 0, otherSize: headerHeight)
    timelinePager.alignAndFill(align: .underCentered, relativeTo: dayHeaderView, padding: 0)
  }

  func updateTimeline(_ timeline: TimelineView) {
    guard let dataSource = dataSource else {return}
    let events = dataSource.eventsForDate(timeline.date)
    timeline.eventDescriptors = events
  }
}


  open var autoScrollToFirstEvent = false

  let dayHeaderView = DayHeaderView()
  let timelinePagerView = TimelinePagerView()

  var currentDate = Date().dateOnly()

