Skip to content

Commit

Permalink
Merge pull request #67 from Inspirato/develop
Browse files Browse the repository at this point in the history
New Version (3.2.2)
  • Loading branch information
justinvallely authored Oct 26, 2017
2 parents e0b9c10 + 725dbd0 commit 84c2d44
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 12 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
## Master

## 3.2.2 (2017-10-26)

##### Bug Fixes

* Fixes bug when rotation occurs on first image and content is offset, or header display causing last page to be scrolled to during that rotation
* Fixes issue for isViewFirstAppearing not being called in certain conditions
* Improves accuracy and efficiency of revolving carousel when header or footer is reached
* Implements fix to prevent infinite scrolling when only one image is present
* Fixes unit tests

## 3.2.1 (2017-10-19)

##### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion Example/Pods/Target Support Files/Nimble/Info.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Example/Tests/SwiftPhotoGalleryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SwiftPhotoGalleryTests: XCTestCase {

let timesAskedForNumberOfImagesInGallery = testHelper.timesAskedForNumberOfImagesInGallery

expect(self.testHelper.timesAskedForNumberOfImagesInGallery).to(equal(2))
expect(self.testHelper.timesAskedForNumberOfImagesInGallery).to(equal(4))

testGallery.dataSource = testHelper

Expand Down
15 changes: 10 additions & 5 deletions Pod/Classes/SwiftPhotoGallery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class SwiftPhotoGallery: UIViewController {

fileprivate var animateImageTransition = false
fileprivate var isViewFirstAppearing = true
fileprivate var deviceInRotation = false

public weak var dataSource: SwiftPhotoGalleryDataSource?
public weak var delegate: SwiftPhotoGalleryDelegate?
Expand Down Expand Up @@ -72,10 +73,11 @@ public class SwiftPhotoGallery: UIViewController {
updatePageControl()
}
get {
pageBeforeRotation = Int(imageCollectionView.contentOffset.x / imageCollectionView.frame.size.width)
if isRevolvingCarouselEnabled {
pageBeforeRotation = Int(imageCollectionView.contentOffset.x / imageCollectionView.frame.size.width) - 1
return Int(imageCollectionView.contentOffset.x / imageCollectionView.frame.size.width) - 1
} else {
pageBeforeRotation = Int(imageCollectionView.contentOffset.x / imageCollectionView.frame.size.width)
return Int(imageCollectionView.contentOffset.x / imageCollectionView.frame.size.width)
}
}
Expand Down Expand Up @@ -144,7 +146,7 @@ public class SwiftPhotoGallery: UIViewController {
if needsLayout {
let desiredIndexPath = IndexPath(item: pageBeforeRotation, section: 0)

if pageBeforeRotation > 0 {
if pageBeforeRotation >= 0 {
scrollToImage(withIndex: pageBeforeRotation, animated: false)
}

Expand All @@ -168,15 +170,16 @@ public class SwiftPhotoGallery: UIViewController {
pageControl.currentPageIndicatorTintColor = UIColor.white
pageControl.pageIndicatorTintColor = UIColor(white: 0.75, alpha: 0.35) //Dim Gray

isRevolvingCarouselEnabled = numberOfImages > 1
setupPageControl()
setupGestureRecognizers()
}

public override func viewDidAppear(_ animated: Bool) {
if currentPage < 0 {
currentPage = 0
isViewFirstAppearing = false
}
isViewFirstAppearing = false
}

#if os(iOS)
Expand All @@ -191,6 +194,7 @@ public class SwiftPhotoGallery: UIViewController {
// MARK: Rotation Handling
public override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
deviceInRotation = true
needsLayout = true
}

Expand Down Expand Up @@ -482,12 +486,13 @@ extension SwiftPhotoGallery: UICollectionViewDelegate {
}

public func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
if !collectionView.visibleSupplementaryViews(ofKind: UICollectionElementKindSectionFooter).isEmpty {
if !collectionView.visibleSupplementaryViews(ofKind: UICollectionElementKindSectionFooter).isEmpty && !deviceInRotation || (currentPage == numberOfImages && !deviceInRotation) {
currentPage = 0
}
if !collectionView.visibleSupplementaryViews(ofKind: UICollectionElementKindSectionHeader).isEmpty {
if !collectionView.visibleSupplementaryViews(ofKind: UICollectionElementKindSectionHeader).isEmpty && !deviceInRotation || (currentPage == -1 && !deviceInRotation) {
currentPage = numberOfImages - 1
}
deviceInRotation = false
}
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ A full screen photo gallery for iOS and tvOS written in Swift.
To run the example project, clone the repo, and run `pod install` from the Example directory.

## Requirements
- iOS 8.3+
- iOS 9.0+
- tvOS 10.0+
- Xcode 8.0+
- Swift 3.0+
Expand Down
2 changes: 1 addition & 1 deletion SwiftPhotoGallery.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = "SwiftPhotoGallery"
s.version = "3.2.1"
s.version = "3.2.2"
s.summary = "Photo gallery for iOS and tvOS written in Swift"
s.description = <<-DESC
"Photo gallery for iOS and tvOS written in Swift. Photos can be panned and zoomed (iOS). Includes a customizable page indicator, support for any orientation (iOS), and supports images of varying sizes. Includes unit tests."
Expand Down

0 comments on commit 84c2d44

Please sign in to comment.