diff --git a/MagazineLayout/Public/MagazineLayout.swift b/MagazineLayout/Public/MagazineLayout.swift index 83576e3..efb68bc 100755 --- a/MagazineLayout/Public/MagazineLayout.swift +++ b/MagazineLayout/Public/MagazineLayout.swift @@ -30,24 +30,21 @@ public final class MagazineLayout: UICollectionViewLayout { /// - flipsHorizontallyInOppositeLayoutDirection: Indicates whether the horizontal coordinate /// system is automatically flipped at appropriate times. In practice, this is used to support /// right-to-left layout. - /// - verticalLayoutDirection: The vertical layout direction of items in the collection view. This property changes the - /// behavior of scroll-position-preservation when performing batch updates or when the collection view's bounds changes. - public init( - flipsHorizontallyInOppositeLayoutDirection: Bool = true, - verticalLayoutDirection: MagazineLayoutVerticalLayoutDirection = .topToBottom) - { + public init(flipsHorizontallyInOppositeLayoutDirection: Bool = true) { _flipsHorizontallyInOppositeLayoutDirection = flipsHorizontallyInOppositeLayoutDirection - self.verticalLayoutDirection = verticalLayoutDirection super.init() } required init?(coder aDecoder: NSCoder) { _flipsHorizontallyInOppositeLayoutDirection = true - verticalLayoutDirection = .topToBottom super.init(coder: aDecoder) } // MARK: Public + + /// The vertical layout direction of items in the collection view. This property changes the behavior of + /// scroll-position-preservation when performing batch updates or when the collection view's bounds changes. + public var verticalLayoutDirection = MagazineLayoutVerticalLayoutDirection.topToBottom override public class var layoutAttributesClass: AnyClass { return MagazineLayoutCollectionViewLayoutAttributes.self @@ -844,7 +841,6 @@ public final class MagazineLayout: UICollectionViewLayout { // MARK: Private private let _flipsHorizontallyInOppositeLayoutDirection: Bool - private let verticalLayoutDirection: MagazineLayoutVerticalLayoutDirection private lazy var modelState: ModelState = { return ModelState(currentVisibleBoundsProvider: { [weak self] in diff --git a/Tests/ContentInsetAdjustingContentOffsetTests.swift b/Tests/ContentInsetAdjustingContentOffsetTests.swift index 71da29f..8ab05d0 100644 --- a/Tests/ContentInsetAdjustingContentOffsetTests.swift +++ b/Tests/ContentInsetAdjustingContentOffsetTests.swift @@ -19,7 +19,7 @@ import XCTest final class ContentInsetAdjustingContentOffsetTests: XCTestCase { func testContentOffsetIsNotAdjustedForTopInsetChangeWithToTopBottomLayout() { - let layout = MagazineLayout(verticalLayoutDirection: .topToBottom) + let layout = MagazineLayout() let collectionView = StubCollectionView( frame: .zero, collectionViewLayout: layout) @@ -33,7 +33,8 @@ final class ContentInsetAdjustingContentOffsetTests: XCTestCase { } func testContentOffsetIsAdjustedForTopInsetChangeWithBottomToTopLayout() { - let layout = MagazineLayout(verticalLayoutDirection: .bottomToTop) + let layout = MagazineLayout() + layout.verticalLayoutDirection = .bottomToTop let collectionView = StubCollectionView( frame: .zero, collectionViewLayout: layout) @@ -47,7 +48,8 @@ final class ContentInsetAdjustingContentOffsetTests: XCTestCase { } func testContentOffsetIsAdjustedForBottomInsetChangeWithBottomToTopLayout() { - let layout = MagazineLayout(verticalLayoutDirection: .bottomToTop) + let layout = MagazineLayout() + layout.verticalLayoutDirection = .bottomToTop let collectionView = StubCollectionView( frame: .zero, collectionViewLayout: layout) @@ -61,7 +63,8 @@ final class ContentInsetAdjustingContentOffsetTests: XCTestCase { } func testContentOffsetIsAdjustedForTopAndBottomInsetChangesWithBottomToTopLayout() { - let layout = MagazineLayout(verticalLayoutDirection: .bottomToTop) + let layout = MagazineLayout() + layout.verticalLayoutDirection = .bottomToTop let collectionView = StubCollectionView( frame: .zero, collectionViewLayout: layout)