title: how to make a collection view to scroll horizontally having infinite scroll in both directions left, as well as right in iOS swift
body: <p>I want a horizontal scrollable collection view  to scroll in both side(left and right), now it has continuous scrolling only in right direction, how to implement in left side ?</p>
  <pre><code>let itemcount = array?.count ?? 0
  func scrollViewDidScroll(_ scrollView: UIScrollView) {
                  if scrollView == DemoCollectionView {
                      let offSet = scrollView.contentOffset.x
                      let width = scrollView.frame.width
                      let horizontalCenter = width / 2
                      let currentPage = Int(offSet + horizontalCenter) / Int(width)
                      if currentPage &gt;= itemCount / 2 {
                          itemCount += array?.count ?? 0
                          DemoCollectionView.reloadData()
                      }
                  }
              }
  </code></pre>