CoverHorizontalAnimation.swift 714 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // CoverHorizontalAnimation.swift
  3. // Presentr
  4. //
  5. // Created by Daniel Lozano on 5/15/16.
  6. // Copyright © 2016 danielozano. All rights reserved.
  7. //
  8. import UIKit
  9. public class CoverHorizontalAnimation: PresentrAnimation {
  10. private var fromRight: Bool
  11. public init(fromRight: Bool = true) {
  12. self.fromRight = fromRight
  13. }
  14. override public func transform(containerFrame: CGRect, finalFrame: CGRect) -> CGRect {
  15. var initialFrame = finalFrame
  16. if fromRight {
  17. initialFrame.origin.x = containerFrame.size.width + initialFrame.size.width
  18. } else {
  19. initialFrame.origin.x = 0 - initialFrame.size.width
  20. }
  21. return initialFrame
  22. }
  23. }