From 933d7726a4dbfd619505b6e1d65b826c4d30fdcf Mon Sep 17 00:00:00 2001 From: Philippe Riegert Date: Fri, 27 May 2016 21:45:46 -0400 Subject: [PATCH 1/3] add a delegate to notify when the user scroll to an index --- SKPhotoBrowser/SKPhotoBrowser.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SKPhotoBrowser/SKPhotoBrowser.swift b/SKPhotoBrowser/SKPhotoBrowser.swift index 3023a85..b529dc0 100644 --- a/SKPhotoBrowser/SKPhotoBrowser.swift +++ b/SKPhotoBrowser/SKPhotoBrowser.swift @@ -45,7 +45,14 @@ import UIKit - Parameter photoIndex: the index of the current photo */ optional func didDismissActionSheetWithButtonIndex(buttonIndex: Int, photoIndex: Int) - + + /** + Tells the delegate that the browser did scroll to index + + - Parameter index: the index of the photo where the user had scroll + */ + optional func didScrollToIndex(index: Int) + /** Tells the delegate the user removed a photo, when implementing this call, be sure to call reload to finish the deletion process @@ -1256,6 +1263,9 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate { public func scrollViewDidEndDecelerating(scrollView: UIScrollView) { hideControlsAfterDelay() + + let currentIndex = self.pagingScrollView.contentOffset.x / self.pagingScrollView.frame.size.width + self.delegate?.didScrollToIndex?(Int(currentIndex)) } public func scrollViewDidEndScrollingAnimation(scrollView: UIScrollView) { From 71ff3d48b701d550c79f1d84d1d6a05da6a7624d Mon Sep 17 00:00:00 2001 From: Philippe Riegert Date: Sat, 28 May 2016 00:15:31 -0400 Subject: [PATCH 2/3] add missing delegate in the doc --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 21a90d9..7e5166a 100644 --- a/README.md +++ b/README.md @@ -151,9 +151,11 @@ browser.disableVerticalSwipe = true There's some trigger point you can handle using delegate. those are optional. - didShowPhotoAtIndex(index:Int) - willDismissAtPageIndex(index:Int) +- willShowActionSheet(photoIndex: Int) - didDismissAtPageIndex(index:Int) - didDismissActionSheetWithButtonIndex(buttonIndex: Int, photoIndex: Int) - removePhoto(browser: SKPhotoBrowser, index: Int, reload: (() -> Void)) +- viewForPhoto(browser: SKPhotoBrowser, index: Int) -> UIView? ```swift let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell) From 3e2a11512724a371bcae9ee83e4899b9e7d3dcf1 Mon Sep 17 00:00:00 2001 From: Philippe Riegert Date: Sat, 28 May 2016 00:15:51 -0400 Subject: [PATCH 3/3] add the new delegate in the doc --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7e5166a..aa2dd5c 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ There's some trigger point you can handle using delegate. those are optional. - willShowActionSheet(photoIndex: Int) - didDismissAtPageIndex(index:Int) - didDismissActionSheetWithButtonIndex(buttonIndex: Int, photoIndex: Int) +- didScrollToIndex(index: Int) - removePhoto(browser: SKPhotoBrowser, index: Int, reload: (() -> Void)) - viewForPhoto(browser: SKPhotoBrowser, index: Int) -> UIView?