Skip to content

Commit

Permalink
Fixes #66
Browse files Browse the repository at this point in the history
  • Loading branch information
0ber committed Jan 29, 2018
1 parent 03704d1 commit fc70562
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DemoViewController: ExpandingViewController {
extension DemoViewController {

override func viewDidLoad() {
itemSize = CGSize(width: 256, height: 335)
itemSize = CGSize(width: 256, height: 460)
super.viewDidLoad()

registerCell()
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,17 @@ The [iPhone mockup](https://store.ramotion.com?utm_source=gthb&utm_medium=specia
## Requirements

- iOS 9.0+
- Xcode 8
- Xcode 9.0+

## Installation

Just add the Source folder to your project.

or use [CocoaPods](https://cocoapods.org) with Podfile:
``` ruby
pod 'expanding-collection', '~> 1.1.2' swift 4

pod 'expanding-collection', '~> 1.0.3' swift 3

pod 'expanding-collection', '~> 0.3.2' swift 2
pod 'expanding-collection'
```

or [Carthage](https://github.com/Carthage/Carthage) users can simply add to their `Cartfile`:
```
github "Ramotion/expanding-collection"
Expand Down Expand Up @@ -84,7 +81,7 @@ import expanding_collection

``` swift
override func viewDidLoad() {
itemSize = CGSize(width: 214, height: 264)
itemSize = CGSize(width: 214, height: 460) //IMPORTANT!!! Height of open state cell
super.viewDidLoad()

// register cell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ extension BasePageCollectionCell {
if isOpen == isOpened { return }

if ySpacing == .greatestFiniteMagnitude {
frontConstraintY.constant = isOpen == true ? -frontContainerView.bounds.size.height / 5 : 0
backConstraintY.constant = isOpen == true ? frontContainerView.bounds.size.height / 5 - yOffset / 2 : 0
frontConstraintY.constant = isOpen == true ? -frontContainerView.bounds.size.height / 6 : 0
backConstraintY.constant = isOpen == true ? frontContainerView.bounds.size.height / 6 - yOffset / 2 : 0
} else {
frontConstraintY.constant = isOpen == true ? -ySpacing / 2 : 0
backConstraintY.constant = isOpen == true ? ySpacing / 2 : 0
Expand All @@ -133,7 +133,6 @@ extension BasePageCollectionCell {
}

isOpened = isOpen
configurationCell()

if animated == true {
UIView.animate(withDuration: 0.3, delay: 0, options: UIViewAnimationOptions(), animations: {
Expand Down Expand Up @@ -204,22 +203,6 @@ extension BasePageCollectionCell {
return shadow
}

func configurationCell() {
// Prevents indefinite growing of the cell issue
let i: CGFloat = isOpened ? 1 : -1
let superHeight = superview?.frame.size.height ?? 0

frame.size.height += i * superHeight
frame.origin.y -= i * superHeight / 2
if additionalWidth == .greatestFiniteMagnitude {
frame.origin.x -= i * yOffset / 2
frame.size.width += i * yOffset
} else {
frame.origin.x -= i * additionalWidth / 2
frame.size.width += i * additionalWidth
}
}

func configureCellViewConstraintsWithSize(_ size: CGSize) {
guard isOpened == false && frontContainerView.getConstraint(.width)?.constant != size.width else { return }

Expand Down
6 changes: 3 additions & 3 deletions Source/ExpandingViewController/ExpandingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import UIKit
/// UIViewController with UICollectionView with custom transition method
open class ExpandingViewController: UIViewController {

/// The default size to use for cells.
open var itemSize = CGSize(width: 256, height: 335)
/// The default size to use for cells. Height of open cell state
open var itemSize = CGSize(width: 256, height: 460)

/// The collection view object managed by this view controller.
open var collectionView: UICollectionView?
Expand Down Expand Up @@ -86,7 +86,7 @@ extension ExpandingViewController {
let layout = PageCollectionLayout(itemSize: itemSize)
collectionView = PageCollectionView.createOnView(view,
layout: layout,
height: itemSize.height + itemSize.height / 5 * 2,
height: itemSize.height,
dataSource: self,
delegate: self)
if #available(iOS 10.0, *) {
Expand Down

0 comments on commit fc70562

Please sign in to comment.