diff --git a/HFSwipeView/Classes/HFSwipeView+AutoSlide.swift b/HFSwipeView/Classes/HFSwipeView+AutoSlide.swift index 978b818..e36fb50 100644 --- a/HFSwipeView/Classes/HFSwipeView+AutoSlide.swift +++ b/HFSwipeView/Classes/HFSwipeView+AutoSlide.swift @@ -14,7 +14,7 @@ extension HFSwipeView { /// zero or minus interval disables auto slide. public func startAutoSlide(forTimeInterval timeInterval: TimeInterval) { if !circulating { - logw("Cannot use auto-slide without circulation mode.") + // logw("Cannot use auto-slide without circulation mode.") return } if timeInterval > 0 { @@ -31,7 +31,7 @@ extension HFSwipeView { public func pauseAutoSlide() { if !circulating { - logw("Cannot use auto-slide without circulation mode.") + // logw("Cannot use auto-slide without circulation mode.") return } if autoSlideInterval > 0 { @@ -44,7 +44,7 @@ extension HFSwipeView { public func resumeAutoSlide() { if !circulating { - logw("Cannot use auto-slide without circulation mode.") + // logw("Cannot use auto-slide without circulation mode.") return } if autoSlideIntervalBackupForLaterUse > 0 { @@ -54,7 +54,7 @@ extension HFSwipeView { public func stopAutoSlide() { if !circulating { - logw("Cannot use auto-slide without circulation mode.") + // logw("Cannot use auto-slide without circulation mode.") return } autoSlideInterval = -1 @@ -68,7 +68,7 @@ extension HFSwipeView { return } DispatchQueue.main.async { - self.movePage((self.currentPage + 1) % self.count, animated: true) + self.movePage((self.currentPage + self.count + 1), animated: true) } } } diff --git a/HFSwipeView/Classes/HFSwipeView+Delegate.swift b/HFSwipeView/Classes/HFSwipeView+Delegate.swift index e34bf3f..15289af 100644 --- a/HFSwipeView/Classes/HFSwipeView+Delegate.swift +++ b/HFSwipeView/Classes/HFSwipeView+Delegate.swift @@ -17,7 +17,7 @@ extension HFSwipeView: UICollectionViewDataSource { } public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - log("\(realViewCount)") + // log("\(realViewCount)") return realViewCount } @@ -33,7 +33,7 @@ extension HFSwipeView: UICollectionViewDataSource { let cell: UICollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: kSwipeViewCellIdentifier, for: indexPath) guard let dataSource = self.dataSource else { - loge("dataSource is nil") + // loge("dataSource is nil") return cell } @@ -66,15 +66,15 @@ extension HFSwipeView: UICollectionViewDataSource { } if displayIndex.row == currentPage { - log("[CURRENT][\(displayIndex.row)/\(indexPath.row)]") + // log("[CURRENT][\(displayIndex.row)/\(indexPath.row)]") if indexPath.row == currentRealPage { dataSource.swipeView?(self, needUpdateCurrentViewForIndexPath: displayIndex, view: cellView!) } else { - log("[NORMAL][\(displayIndex.row)/\(indexPath.row)]") + // log("[NORMAL][\(displayIndex.row)/\(indexPath.row)]") dataSource.swipeView?(self, needUpdateViewForIndexPath: displayIndex, view: cellView!) } } else { - log("[NORMAL][\(displayIndex.row)/\(indexPath.row)]") + // log("[NORMAL][\(displayIndex.row)/\(indexPath.row)]") dataSource.swipeView?(self, needUpdateViewForIndexPath: displayIndex, view: cellView!) } addDebugInfo(view: cellView!, realIndex: indexPath.row, dispIndex: displayIndex.row) @@ -84,7 +84,7 @@ extension HFSwipeView: UICollectionViewDataSource { internal func cellForItemInNormalMode(_ collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { let cell: UICollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: kSwipeViewCellIdentifier, for: indexPath) guard let dataSource = self.dataSource else { - loge("dataSource is nil") + // loge("dataSource is nil") return cell } var cellView: UIView? = nil @@ -145,12 +145,12 @@ extension HFSwipeView: UICollectionViewDelegateFlowLayout { public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { guard var itemSize = self.itemSize else { - loge("item size not provided") + // loge("item size not provided") return .zero } if frame.size.width < itemSize.width { - loge("item size cannot exceeds parent swipe view") + // loge("item size cannot exceeds parent swipe view") return .zero } @@ -217,11 +217,11 @@ extension HFSwipeView: UIScrollViewDelegate { } public func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) { - log("[\(self.tag)]") + // log("[\(self.tag)]") } public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) { - log("[\(self.tag)]: \(scrollView.contentOffset.x), velocity: \(velocity.x), target: \(targetContentOffset.pointee.x)") + // log("[\(self.tag)]: \(scrollView.contentOffset.x), velocity: \(velocity.x), target: \(targetContentOffset.pointee.x)") } public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { @@ -236,7 +236,7 @@ extension HFSwipeView: UIScrollViewDelegate { } public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { - log("[\(self.tag)]") + // log("[\(self.tag)]") updateIndexBasedOnContentOffset() if circulating { diff --git a/HFSwipeView/Classes/HFSwipeView+Index.swift b/HFSwipeView/Classes/HFSwipeView+Index.swift index ae4a96e..1dfc4ce 100644 --- a/HFSwipeView/Classes/HFSwipeView+Index.swift +++ b/HFSwipeView/Classes/HFSwipeView+Index.swift @@ -78,7 +78,7 @@ extension HFSwipeView { } } - log("[\(self.tag)]: from: \(from) to: \(minIdx)") + // log("[\(self.tag)]: from: \(from) to: \(minIdx)") return IndexPath(item: minIdx, section: 0) } @@ -129,7 +129,7 @@ extension HFSwipeView { } else { displayIndex = realIndex.row - count - dummyCount } - log("[\(self.tag)]: \(realIndex.row) -> \(displayIndex)") + // log("[\(self.tag)]: \(realIndex.row) -> \(displayIndex)") return IndexPath(item: displayIndex, section: 0) } else { return IndexPath(item: realIndex.row, section: 0) @@ -144,7 +144,7 @@ extension HFSwipeView { if 0 <= displayIndex.row && displayIndex.row < count { index = displayIndex.row + dummyCount } - log("[\(self.tag)]: \(displayIndex.row) -> \(index)") + // log("[\(self.tag)]: \(displayIndex.row) -> \(index)") return IndexPath(item: index, section: 0) } @@ -178,7 +178,7 @@ extension HFSwipeView { } guard let indexPath = indexPathForItemAtPoint(collectionView.contentOffset) else { - logw("indexPathForItemAtPoint returned nil.") + // logw("indexPathForItemAtPoint returned nil.") return } @@ -194,9 +194,9 @@ extension HFSwipeView { if let view = indexViewMapper[currentRealPage] { dataSource?.swipeView?(self, needUpdateCurrentViewForIndexPath: displayIndex, view: view) } else { - logw("Failed to retrieve current view from indexViewMapper for indexPath: \(indexPath.row)") + // logw("Failed to retrieve current view from indexViewMapper for indexPath: \(indexPath.row)") } - log("[\(self.tag)]: \(currentPage)/\(count - 1) - \(currentRealPage)/\(realViewCount - 1)") + // log("[\(self.tag)]: \(currentPage)/\(count - 1) - \(currentRealPage)/\(realViewCount - 1)") } } @@ -205,7 +205,7 @@ extension HFSwipeView { guard let indexPath = indexPathForItemAtPoint(collectionView.contentOffset) else { return } - log("[\(self.tag)]: real -> \(indexPath.row)") + // log("[\(self.tag)]: real -> \(indexPath.row)") let displayIndex = displayIndexUsing(indexPath) delegate?.swipeView?(self, didFinishScrollAtIndexPath: displayIndex) diff --git a/HFSwipeView/Classes/HFSwipeView+Offset.swift b/HFSwipeView/Classes/HFSwipeView+Offset.swift index 801f5f0..1aed705 100644 --- a/HFSwipeView/Classes/HFSwipeView+Offset.swift +++ b/HFSwipeView/Classes/HFSwipeView+Offset.swift @@ -45,7 +45,7 @@ extension HFSwipeView { // corrected index guard let proposedIndexPath = indexPathForItemAtPoint(proposedOffset) else { - loge("nearestIndexPath is nil") + // loge("nearestIndexPath is nil") return .zero } @@ -99,12 +99,12 @@ extension HFSwipeView { if offset.x < dummyWidth { let delta = dummyWidth - offset.x setContentOffsetWithoutCallingDelegate(CGPoint(x: contentSize.width - dummyWidth - delta, y: 0)) - log("[\(self.tag)]: moved to last view, offset: \(scrollView.contentOffset)") + // log("[\(self.tag)]: moved to last view, offset: \(scrollView.contentOffset)") return true } else if offset.x >= contentSize.width - dummyWidth { let delta = offset.x - (contentSize.width - dummyWidth) setContentOffsetWithoutCallingDelegate(CGPoint(x: self.dummyWidth + delta, y: 0)) - log("[\(self.tag)]: moved to first view!, offset: \(scrollView.contentOffset)") + // log("[\(self.tag)]: moved to first view!, offset: \(scrollView.contentOffset)") return true } return false diff --git a/HFSwipeView/Classes/HFSwipeView+Page.swift b/HFSwipeView/Classes/HFSwipeView+Page.swift index e540161..07661fd 100644 --- a/HFSwipeView/Classes/HFSwipeView+Page.swift +++ b/HFSwipeView/Classes/HFSwipeView+Page.swift @@ -14,10 +14,10 @@ extension HFSwipeView { internal func moveRealPage(_ realPage: Int, animated: Bool) { if realPage >= 0 && realPage < realViewCount && realPage == currentRealPage { - log("moveRealPage received same page(\(realPage)) == currentPage(\(currentRealPage))") + // log("moveRealPage received same page(\(realPage)) == currentPage(\(currentRealPage))") return } - log("[\(self.tag)]: \(realPage)") + // log("[\(self.tag)]: \(realPage)") let realIndex = IndexPath(item: realPage, section: 0) @@ -37,7 +37,7 @@ extension HFSwipeView { if let view = indexViewMapper[currentRealPage] { dataSource?.swipeView?(self, needUpdateCurrentViewForIndexPath: displayIndex, view: view) } else { - logw("Failed to retrieve current view from indexViewMapper for indexPath: \(displayIndex.row)") + // logw("Failed to retrieve current view from indexViewMapper for indexPath: \(displayIndex.row)") } } @@ -53,6 +53,6 @@ extension HFSwipeView { collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true) } } - log("[\(self.tag)]: real -> \(indexPath.row)") + // log("[\(self.tag)]: real -> \(indexPath.row)") } } diff --git a/HFSwipeView/Classes/HFSwipeView.swift b/HFSwipeView/Classes/HFSwipeView.swift index d6dd18e..98d9bfc 100644 --- a/HFSwipeView/Classes/HFSwipeView.swift +++ b/HFSwipeView/Classes/HFSwipeView.swift @@ -77,11 +77,11 @@ open class HFSwipeView: UIView { internal var contentInsets: UIEdgeInsets { if var insets = dataSource?.swipeViewContentInsets?(self) { if insets.top != 0 { - logw("Changing UIEdgeInsets.top for HFSwipeView is not supported yet, consider a container view instead.") + // logw("Changing UIEdgeInsets.top for HFSwipeView is not supported yet, consider a container view instead.") insets.top = 0 } if insets.bottom != 0 { - logw("Changing UIEdgeInsets.bottom for HFSwipeView is not supported yet, consider a container view instead.") + // logw("Changing UIEdgeInsets.bottom for HFSwipeView is not supported yet, consider a container view instead.") insets.bottom = 0 } return insets @@ -141,11 +141,11 @@ open class HFSwipeView: UIView { open var count: Int { // showing count if circulating { if realViewCount < 0 { - loge("cannot use property \"count\" before set HFSwipeView.realViewCount") + // loge("cannot use property \"count\" before set HFSwipeView.realViewCount") return -1 } if realViewCount > 0 { - return realViewCount - 2 * dummyCount + return realViewCount - 1 * dummyCount } else { return 0 } @@ -227,7 +227,7 @@ open class HFSwipeView: UIView { } deinit { - logi("Successfully released HFSwipeView object.") + // logi("Successfully released HFSwipeView object.") } fileprivate func prepareForInteraction() { @@ -240,19 +240,19 @@ open class HFSwipeView: UIView { // retrieve item distance itemSpace = cgfloat(dataSource?.swipeViewItemDistance?(self), defaultValue: 0) - log("successfully set itemSpace: \(itemSpace)") + // log("successfully set itemSpace: \(itemSpace)") // retrieve item size itemSize = dataSource?.swipeViewItemSize(self) guard let itemSize = itemSize else { - loge("item size not provided") + // loge("item size not provided") return false } if itemSize == CGSize.zero { - loge("item size error: CGSizeZero") + // loge("item size error: CGSizeZero") return false } else { - log("itemSize is \(itemSize)") + // log("itemSize is \(itemSize)") } // retrieve item count @@ -265,17 +265,17 @@ open class HFSwipeView: UIView { // if given width is wider than needed space if itemCount > 0 { itemSpace = (frame.size.width - (itemSize.width * CGFloat(itemCount))) / CGFloat(itemCount) - logw("successfully fixed itemSpace: \(itemSpace)") + // logw("successfully fixed itemSpace: \(itemSpace)") } } dummyCount = itemCount if dummyCount >= 1 { dummyWidth = CGFloat(dummyCount) * (itemSize.width + itemSpace) - log("successfully set dummyCount: \(dummyCount), dummyWidth: \(dummyWidth)") + // log("successfully set dummyCount: \(dummyCount), dummyWidth: \(dummyWidth)") } realViewCount = itemCount > 0 ? itemCount + dummyCount * 2 : 0 - log("successfully set realViewCount: \(realViewCount)") + // log("successfully set realViewCount: \(realViewCount)") } else { collectionView.alwaysBounceHorizontal = true @@ -290,7 +290,7 @@ open class HFSwipeView: UIView { } (collectionView.collectionViewLayout as? HFSwipeViewFlowLayout)?.itemSize = itemSize setContentSizeWithoutCallingDelegate(contentSize) - log("successfully set content size: \(collectionView.contentSize)") + // log("successfully set content size: \(collectionView.contentSize)") return true } @@ -351,7 +351,7 @@ extension HFSwipeView { open func movePage(_ page: Int, animated: Bool) { if page == currentPage { - log("movePage received same page(\(page)) == currentPage(\(currentPage))") + // log("movePage received same page(\(page)) == currentPage(\(currentPage))") autoAlign(collectionView, indexPath: IndexPath(item: currentRealPage, section: 0)) return }