Skip to content

Commit

Permalink
Renamed PagerCollectionViewLayoutAttributes to AnimatedCollectionView…
Browse files Browse the repository at this point in the history
…LayoutAttributes
  • Loading branch information
KelvinJin committed Feb 22, 2017
1 parent 789e510 commit 34cf7a8
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions Source/AnimatedCollectionViewLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public class AnimatedCollectionViewLayout: UICollectionViewFlowLayout {
public var animator: LayoutAttributesAnimator?

/// Overrided so that we can store extra information in the layout attributes.
public override class var layoutAttributesClass: AnyClass { return PagerCollectionViewLayoutAttributes.self }
public override class var layoutAttributesClass: AnyClass { return AnimatedCollectionViewLayoutAttributes.self }

public override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
guard let attributes = super.layoutAttributesForElements(in: rect) else { return nil }
return attributes.flatMap { $0.copy() as? PagerCollectionViewLayoutAttributes }.map { self.transformLayoutAttributes($0) }
return attributes.flatMap { $0.copy() as? AnimatedCollectionViewLayoutAttributes }.map { self.transformLayoutAttributes($0) }
}

public override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
Expand All @@ -29,7 +29,7 @@ public class AnimatedCollectionViewLayout: UICollectionViewFlowLayout {
return true
}

private func transformLayoutAttributes(_ attributes: PagerCollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
private func transformLayoutAttributes(_ attributes: AnimatedCollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {

guard let collectionView = self.collectionView else { return attributes }

Expand Down Expand Up @@ -73,7 +73,7 @@ public class AnimatedCollectionViewLayout: UICollectionViewFlowLayout {
}

/// A custom layout attributes that contains extra information.
public class PagerCollectionViewLayoutAttributes: UICollectionViewLayoutAttributes {
public class AnimatedCollectionViewLayoutAttributes: UICollectionViewLayoutAttributes {
public var contentView: UIView?
public var scrollDirection: UICollectionViewScrollDirection = .vertical

Expand All @@ -82,7 +82,7 @@ public class PagerCollectionViewLayoutAttributes: UICollectionViewLayoutAttribut
public var endOffset: CGFloat = 0

public override func copy(with zone: NSZone? = nil) -> Any {
let copy = super.copy(with: zone) as! PagerCollectionViewLayoutAttributes
let copy = super.copy(with: zone) as! AnimatedCollectionViewLayoutAttributes
copy.contentView = contentView
copy.scrollDirection = scrollDirection
copy.startOffset = startOffset
Expand All @@ -92,7 +92,7 @@ public class PagerCollectionViewLayoutAttributes: UICollectionViewLayoutAttribut
}

public override func isEqual(_ object: Any?) -> Bool {
guard let o = object as? PagerCollectionViewLayoutAttributes else { return false }
guard let o = object as? AnimatedCollectionViewLayoutAttributes else { return false }

return o.contentView == contentView
&& o.scrollDirection == scrollDirection
Expand Down
2 changes: 1 addition & 1 deletion Source/CrossFadeAttributesAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import UIKit
public struct CrossFadeAttributeAnimator: LayoutAttributesAnimator {
public init() {}

public func animate(collectionView: UICollectionView, attributes: PagerCollectionViewLayoutAttributes) {
public func animate(collectionView: UICollectionView, attributes: AnimatedCollectionViewLayoutAttributes) {
let position = attributes.middleOffset
let contentOffset = collectionView.contentOffset
attributes.frame = CGRect(origin: contentOffset, size: attributes.frame.size)
Expand Down
2 changes: 1 addition & 1 deletion Source/CubeAttributesAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct CubeAttributeAnimator: LayoutAttributesAnimator {
self.totalAngle = totalAngle
}

public func animate(collectionView: UICollectionView, attributes: PagerCollectionViewLayoutAttributes) {
public func animate(collectionView: UICollectionView, attributes: AnimatedCollectionViewLayoutAttributes) {
let position = attributes.middleOffset
if abs(position) >= 1 {
attributes.contentView?.layer.transform = CATransform3DIdentity
Expand Down
2 changes: 1 addition & 1 deletion Source/LayoutAttributesAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
import UIKit

public protocol LayoutAttributesAnimator {
func animate(collectionView: UICollectionView, attributes: PagerCollectionViewLayoutAttributes)
func animate(collectionView: UICollectionView, attributes: AnimatedCollectionViewLayoutAttributes)
}
2 changes: 1 addition & 1 deletion Source/LinearCardAttributesAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public struct LinearCardAttributeAnimator: LayoutAttributesAnimator {
self.scaleRate = scaleRate
}

public func animate(collectionView: UICollectionView, attributes: PagerCollectionViewLayoutAttributes) {
public func animate(collectionView: UICollectionView, attributes: AnimatedCollectionViewLayoutAttributes) {
let position = attributes.middleOffset
let scaleFactor = scaleRate - 0.1 * abs(position)
let scaleTransform = CGAffineTransform(scaleX: scaleFactor, y: scaleFactor)
Expand Down
2 changes: 1 addition & 1 deletion Source/PageAttributesAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct PageAttributeAnimator: LayoutAttributesAnimator {
self.scaleRate = scaleRate
}

public func animate(collectionView: UICollectionView, attributes: PagerCollectionViewLayoutAttributes) {
public func animate(collectionView: UICollectionView, attributes: AnimatedCollectionViewLayoutAttributes) {
let position = attributes.middleOffset
let contentOffset = collectionView.contentOffset
let itemOrigin = attributes.frame.origin
Expand Down
2 changes: 1 addition & 1 deletion Source/ParallaxAttributesAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct ParallaxAttributesAnimator: LayoutAttributesAnimator {
self.speed = speed
}

public func animate(collectionView: UICollectionView, attributes: PagerCollectionViewLayoutAttributes) {
public func animate(collectionView: UICollectionView, attributes: AnimatedCollectionViewLayoutAttributes) {
let position = attributes.middleOffset
let direction = attributes.scrollDirection

Expand Down
2 changes: 1 addition & 1 deletion Source/RotateInOutAttributesAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public struct RotateInOutAttributesAnimator: LayoutAttributesAnimator {
self.maxRotate = maxRotate
}

public func animate(collectionView: UICollectionView, attributes: PagerCollectionViewLayoutAttributes) {
public func animate(collectionView: UICollectionView, attributes: AnimatedCollectionViewLayoutAttributes) {
let position = attributes.middleOffset
if abs(position) >= 1 {
attributes.transform = .identity
Expand Down
2 changes: 1 addition & 1 deletion Source/ZoomInOutAttributesAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public struct ZoomInOutAttributesAnimator: LayoutAttributesAnimator {
self.scaleRate = scaleRate
}

public func animate(collectionView: UICollectionView, attributes: PagerCollectionViewLayoutAttributes) {
public func animate(collectionView: UICollectionView, attributes: AnimatedCollectionViewLayoutAttributes) {
let position = attributes.middleOffset

if position <= 0 && position > -1 {
Expand Down

0 comments on commit 34cf7a8

Please sign in to comment.