Compare commits

..
6 Commits
Author SHA1 Message Date
Alex.k fdea171402 Fixes #18 2016-06-08 16:22:41 +03:00
Alex.k 956a270b1e update podspec 2016-06-08 14:42:29 +03:00
Alex.k b832f9e372 Fixes #17 2016-06-08 14:40:44 +03:00
Alex aa66607cbd Merge pull request #15 from Dershowitz011/master
Readme fixed again.. -_-
2016-06-07 13:38:40 +00:00
Alex.k 2ef07885b7 update podspec 2016-06-07 16:31:37 +03:00
Shantanu R Desai c91a711dd8 Readme fixed again.. -_- 2016-06-07 17:51:18 +05:30
5 changed files with 52 additions and 8 deletions
@@ -22,6 +22,7 @@ class DemoViewController: ExpandingViewController {
extension DemoViewController {
override func viewDidLoad() {
itemSize = CGSize(width: 256, height: 335)
super.viewDidLoad()
registerCell()
@@ -104,7 +105,8 @@ extension DemoViewController {
extension DemoViewController {
func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
override func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
super.collectionView(collectionView, willDisplayCell: cell, forItemAtIndexPath: indexPath)
guard let cell = cell as? DemoCollectionViewCell else { return }
let index = indexPath.row % items.count
+1 -1
View File
@@ -37,7 +37,7 @@ github "Ramotion/expanding-collection"
## Usage
```swift
import expanding_collection
import ExpandingCollection
```
#### Create CollectionViewCell
@@ -101,17 +101,20 @@ extension BasePageCollectionCell {
public func cellIsOpen(isOpen: Bool, animated: Bool = true) {
if isOpen == isOpened { return }
frontConstraintY.constant = isOpen == true ? -bounds.size.height / 5 : 0
backConstraintY.constant = isOpen == true ? bounds.size.height / 5 - yOffset / 2 : 0
frontConstraintY.constant = isOpen == true ? -frontContainerView.bounds.size.height / 5 : 0
backConstraintY.constant = isOpen == true ? frontContainerView.bounds.size.height / 5 - yOffset / 2 : 0
if let widthConstant = backContainerView.getConstraint(.Width) {
widthConstant.constant = isOpen == true ? contentView.bounds.size.width + yOffset : contentView.bounds.size.width
widthConstant.constant = isOpen == true ? frontContainerView.bounds.size.width + yOffset : frontContainerView.bounds.size.width
}
if let heightConstant = backContainerView.getConstraint(.Height) {
heightConstant.constant = isOpen == true ? contentView.bounds.size.height + yOffset : contentView.bounds.size.height
heightConstant.constant = isOpen == true ? frontContainerView.bounds.size.height + yOffset : frontContainerView.bounds.size.height
}
configurationCell()
if animated == true {
UIView.animateWithDuration(0.3, delay: 0, options: .CurveEaseInOut, animations: {
self.contentView.layoutIfNeeded()
@@ -178,6 +181,26 @@ extension BasePageCollectionCell {
return shadow
}
func configurationCell() {
frame.size.height += (superview?.frame.size.height)!
frame.origin.y -= (superview?.frame.size.height)! / 2
frame.origin.x -= yOffset / 2
frame.size.width += yOffset
}
func configureCellViewConstraintsWithSize(size: CGSize) {
guard isOpened == false && frontContainerView.getConstraint(.Width)?.constant != size.width else { return }
[frontContainerView, backContainerView].forEach {
let constraintWidth = $0.getConstraint(.Width)
constraintWidth?.constant = size.width
let constraintHeight = $0.getConstraint(.Height)
constraintHeight?.constant = size.height
}
}
}
// MARK: NSCoding
@@ -105,8 +105,15 @@ extension ExpandingViewController {
// MARK: UICollectionViewDataSource
extension ExpandingViewController: UICollectionViewDataSource, UICollectionViewDelegate{
extension ExpandingViewController: UICollectionViewDataSource, UICollectionViewDelegate {
public func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
guard case let cell as BasePageCollectionCell = cell else {
return
}
cell.configureCellViewConstraintsWithSize(itemSize)
}
public func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
fatalError("need emplementation in subclass")
}
@@ -116,3 +123,15 @@ extension ExpandingViewController: UICollectionViewDataSource, UICollectionViewD
}
}
// MARK: UIScrollViewDelegate
extension ExpandingViewController {
public func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
let indexPath = NSIndexPath(forRow: currentIndex, inSection: 0)
if case let currentCell as BasePageCollectionCell = collectionView?.cellForItemAtIndexPath(indexPath) {
currentCell.configurationCell()
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'expanding-collection'
s.version = '0.1.1'
s.version = '0.2.1'
s.summary = 'Transition animtion from CollectionView to TableView'
s.license = 'MIT'
s.homepage = 'https://github.com/Ramotion/expanding-collection'