From fc705629474f98f79b863e1d60af00ea59a41787 Mon Sep 17 00:00:00 2001 From: Alex K Date: Mon, 29 Jan 2018 11:47:58 +0300 Subject: [PATCH] Fixes #66 --- .../DemoViewController.swift | 2 +- README.md | 11 ++++------ .../Cells/BasePageCollectionCell.swift | 21 ++----------------- .../ExpandingViewController.swift | 6 +++--- 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/DemoExpandingCollection/DemoExpandingCollection/ViewControllers/DemoViewController/DemoViewController.swift b/DemoExpandingCollection/DemoExpandingCollection/ViewControllers/DemoViewController/DemoViewController.swift index 083f6c2..4f15a5c 100644 --- a/DemoExpandingCollection/DemoExpandingCollection/ViewControllers/DemoViewController/DemoViewController.swift +++ b/DemoExpandingCollection/DemoExpandingCollection/ViewControllers/DemoViewController/DemoViewController.swift @@ -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() diff --git a/README.md b/README.md index 5b28c0b..a3a5af3 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ The [iPhone mockup](https://store.ramotion.com?utm_source=gthb&utm_medium=specia ## Requirements - iOS 9.0+ -- Xcode 8 +- Xcode 9.0+ ## Installation @@ -39,12 +39,9 @@ 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" @@ -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 diff --git a/Source/ExpandingViewController/CollectionView/Cells/BasePageCollectionCell.swift b/Source/ExpandingViewController/CollectionView/Cells/BasePageCollectionCell.swift index 6483b93..45f19c9 100644 --- a/Source/ExpandingViewController/CollectionView/Cells/BasePageCollectionCell.swift +++ b/Source/ExpandingViewController/CollectionView/Cells/BasePageCollectionCell.swift @@ -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 @@ -133,7 +133,6 @@ extension BasePageCollectionCell { } isOpened = isOpen - configurationCell() if animated == true { UIView.animate(withDuration: 0.3, delay: 0, options: UIViewAnimationOptions(), animations: { @@ -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 } diff --git a/Source/ExpandingViewController/ExpandingViewController.swift b/Source/ExpandingViewController/ExpandingViewController.swift index e00a9d0..6111311 100644 --- a/Source/ExpandingViewController/ExpandingViewController.swift +++ b/Source/ExpandingViewController/ExpandingViewController.swift @@ -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? @@ -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, *) {