Skip to content

Commit

Permalink
Merge pull request #39 from alexsanderskywork/master
Browse files Browse the repository at this point in the history
Version 1.6.3
  • Loading branch information
alexanderkhitev committed Mar 9, 2016
2 parents 5a1de60 + 1370ffd commit 66125de
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SKPhotoBrowser
========================

[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Cocoapods Compatible](https://img.shields.io/badge/pod-v1.6.2-blue.svg)](http://cocoadocs.org/docsets/SKPhotoBrowser)
[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/SKPhotoBrowser.svg?style=flat)](http://cocoadocs.org/docsets/SKPhotoBrowser)
[![Swift 2.0](https://img.shields.io/badge/Swift-2.0-orange.svg?style=flat)](https://developer.apple.com/swift/)

Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift2.0, based on [IDMPhotoBrowser](https://github.com/ideaismobile/IDMPhotoBrowser), [MWPhotoBrowser](https://github.com/mwaterfall/MWPhotoBrowser).
Expand Down
2 changes: 1 addition & 1 deletion SKPhotoBrowser.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SKPhotoBrowser"
s.version = "1.6.2"
s.version = "1.6.3"
s.summary = "Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift2.0."
s.homepage = "https://github.com/suzuki-0000/SKPhotoBrowser"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
21 changes: 17 additions & 4 deletions SKPhotoBrowser/SKPhotoBrowser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate {
public var displayCloseButton = true // default is true
public var displayCustomCloseButton = false // if it is true displayCloseButton will be false
public var displayCustomDeleteButton = false // if it is true displayDeleteButton will be false
/// This makes it possible zoom in the black area. By default is true
public var enableZoomBlackArea = true

// actions
private var activityViewController: UIActivityViewController!
Expand Down Expand Up @@ -85,7 +87,7 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate {
public var customDeleteButtonEdgeInsets: UIEdgeInsets!

// photo's paging
private var visiblePages: Set<SKZoomingScrollView> = Set()
private var visiblePages = [SKZoomingScrollView]()//: Set<SKZoomingScrollView> = Set()
private var initialPageIndex: Int = 0
private var currentPageIndex: Int = 0

Expand Down Expand Up @@ -122,7 +124,6 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate {
var numberOfPhotos: Int {
return photos.count
}
var deleted = [Int]()
// MARK - Initializer
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
Expand Down Expand Up @@ -275,10 +276,21 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate {

pagingScrollView.frame = frameForPagingScrollView()
pagingScrollView.contentSize = contentSizeForPagingScrollView()

if visiblePages.count > 0 {
let page = visiblePages[currentPageIndex]
page.frame = frameForPageAtIndex(currentPageIndex)
page.setMaxMinZoomScalesForCurrentBounds()
if page.captionView != nil {
page.captionView.frame = frameForCaptionView(page.captionView, index: currentPageIndex)
}
}

pagingScrollView.contentOffset = contentOffsetForPageAtIndex(currentPageIndex)
// where did start
didStartViewingPageAtIndex(currentPageIndex)

toolBar.frame = frameForToolbarAtOrientation()

isPerformingLayout = false
}

Expand Down Expand Up @@ -896,7 +908,8 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate {
page.tag = index + pageIndexTagOffset
page.photo = photoAtIndex(index)

visiblePages.insert(page)
// visiblePages.insert(page)
visiblePages.append(page)
pagingScrollView.addSubview(page)

// if exists caption, insert
Expand Down
22 changes: 13 additions & 9 deletions SKPhotoBrowser/SKZoomingScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public class SKZoomingScrollView: UIScrollView, UIScrollViewDelegate, SKDetectin
let yScale = boundsSize.height / imageSize.height
let minScale: CGFloat = min(xScale, yScale)
var maxScale: CGFloat!

let deviceScreenWidth = UIScreen.mainScreen().bounds.width

if photoImageView.frame.width < deviceScreenWidth {
Expand All @@ -126,7 +126,7 @@ public class SKZoomingScrollView: UIScrollView, UIScrollViewDelegate, SKDetectin
} else {
maxScale = 1.0
}


maximumZoomScale = maxScale
minimumZoomScale = minScale
Expand Down Expand Up @@ -164,7 +164,7 @@ public class SKZoomingScrollView: UIScrollView, UIScrollViewDelegate, SKDetectin

// image
photoImageView.image = image

var photoImageViewFrame = CGRect.zero
photoImageViewFrame.origin = CGPoint.zero
photoImageViewFrame.size = image.size
Expand All @@ -175,7 +175,7 @@ public class SKZoomingScrollView: UIScrollView, UIScrollViewDelegate, SKDetectin

setMaxMinZoomScalesForCurrentBounds()
} else {
// indicator
// indicator
indicatorView.startAnimating()
}

Expand All @@ -186,7 +186,7 @@ public class SKZoomingScrollView: UIScrollView, UIScrollViewDelegate, SKDetectin
indicatorView.stopAnimating()
}


// MARK: - handle tap
public func handleDoubleTap(touchPoint: CGPoint) {
NSObject.cancelPreviousPerformRequestsWithTarget(photoBrowser)
Expand All @@ -207,7 +207,7 @@ public class SKZoomingScrollView: UIScrollView, UIScrollViewDelegate, SKDetectin
// delay control
photoBrowser.hideControlsAfterDelay()
}

public func zoomRectForScrollViewWith(scale: CGFloat, touchPoint: CGPoint) -> CGRect {
let w = frame.size.width / scale
let h = frame.size.height / scale
Expand All @@ -234,12 +234,16 @@ public class SKZoomingScrollView: UIScrollView, UIScrollViewDelegate, SKDetectin

// MARK: - SKDetectingViewDelegate
func handleSingleTap(view: UIView, touch: UITouch) {
photoBrowser.toggleControls()
if photoBrowser.enableZoomBlackArea == true {
photoBrowser.toggleControls()
}
}

func handleDoubleTap(view: UIView, touch: UITouch) {
let needPoint = getViewFramePercent(view, touch: touch)
handleDoubleTap(needPoint)
if photoBrowser.enableZoomBlackArea == true {
let needPoint = getViewFramePercent(view, touch: touch)
handleDoubleTap(needPoint)
}
}

private func getViewFramePercent(view: UIView, touch: UITouch) -> CGPoint {
Expand Down

0 comments on commit 66125de

Please sign in to comment.