Merge pull request #109 from PhilippeRiegert/add_scroll_delegate
add a delegate to notify when the user scroll to an index
This commit is contained in:
commit
b1db89acbf
|
|
@ -151,9 +151,12 @@ 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)
|
||||
- didScrollToIndex(index: Int)
|
||||
- removePhoto(browser: SKPhotoBrowser, index: Int, reload: (() -> Void))
|
||||
- viewForPhoto(browser: SKPhotoBrowser, index: Int) -> UIView?
|
||||
|
||||
```swift
|
||||
let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue