Skip to content
Open
Show file tree
Hide file tree
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: 5 additions & 5 deletions HFSwipeView/Classes/HFSwipeView+AutoSlide.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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)
}
}
}
22 changes: 11 additions & 11 deletions HFSwipeView/Classes/HFSwipeView+Delegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension HFSwipeView: UICollectionViewDataSource {
}

public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
log("\(realViewCount)")
// log("\(realViewCount)")
return realViewCount
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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<CGPoint>) {
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) {
Expand All @@ -236,7 +236,7 @@ extension HFSwipeView: UIScrollViewDelegate {
}

public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
log("[\(self.tag)]")
// log("[\(self.tag)]")
updateIndexBasedOnContentOffset()

if circulating {
Expand Down
14 changes: 7 additions & 7 deletions HFSwipeView/Classes/HFSwipeView+Index.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down Expand Up @@ -178,7 +178,7 @@ extension HFSwipeView {
}

guard let indexPath = indexPathForItemAtPoint(collectionView.contentOffset) else {
logw("indexPathForItemAtPoint returned nil.")
// logw("indexPathForItemAtPoint returned nil.")
return
}

Expand All @@ -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)")
}
}

Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions HFSwipeView/Classes/HFSwipeView+Offset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension HFSwipeView {

// corrected index
guard let proposedIndexPath = indexPathForItemAtPoint(proposedOffset) else {
loge("nearestIndexPath is nil")
// loge("nearestIndexPath is nil")
return .zero
}

Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions HFSwipeView/Classes/HFSwipeView+Page.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)")
}

}
Expand All @@ -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)")
}
}
28 changes: 14 additions & 14 deletions HFSwipeView/Classes/HFSwipeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -227,7 +227,7 @@ open class HFSwipeView: UIView {
}

deinit {
logi("Successfully released HFSwipeView object.")
// logi("Successfully released HFSwipeView object.")
}

fileprivate func prepareForInteraction() {
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down