 import UIKit
 import TABSwiftLayout
 
+enum ScrollDirection {
+  case Vertical
+  case Horizontal
+}
+
 /**
-*  A scrolling content view that respects the auto-layout constraints of its subviews and resizes its content view
+ *  A horizontal scrolling content view that respects the auto-layout constraints of its subviews and resizes its content view
+ *  and the content size of its scrollable area accordingly.
+ */
+public class HorizontalScrollingContentView: VerticalScrollingContentView {
+  override class var scrollDirection: ScrollDirection { return .Horizontal }
+}
+
+/**
+*  A vertical scrolling content view that respects the auto-layout constraints of its subviews and resizes its content view
 *  and the content size of its scrollable area accordingly.
 */
-public class ScrollingContentView: UIView {
+public class VerticalScrollingContentView: UIView {
 
   // MARK: Public properties
   

  /// The content view, to which you should add subviews. Don't add subviews directly to the scroll view.
  public let contentView: UIView
  
  private let scrollView: UIScrollView
  
  // MARK: - Initialization
  
  required init?(coder aDecoder: NSCoder) {
    scrollView = ScrollingContentView.newScrollView()
    contentView = ScrollingContentView.newContentView()
    super.init(coder: aDecoder)
    setupInitialConstraints()
  }
  
  override init(frame: CGRect) {
    scrollView = ScrollingContentView.newScrollView()
    contentView = ScrollingContentView.newContentView()
    super.init(frame: frame)
    setupInitialConstraints()
  }

    scrollView.pin(EdgeMask.All, toView: self, margins: EdgeMargins())
    scrollView.addSubview(contentView)
    
    let topAttribute: NSLayoutAttribute = self.dynamicType.scrollDirection == .Vertical ? .Top : .Leading
    let bottomAttribute: NSLayoutAttribute = self.dynamicType.scrollDirection == .Vertical ? .Bottom : .Trailing
    let leadingAttribute: NSLayoutAttribute = self.dynamicType.scrollDirection == .Vertical ? .Leading : .Top
    let trailingAttribute: NSLayoutAttribute = self.dynamicType.scrollDirection == .Vertical ? .Trailing : .Bottom
    
    // the content view is constrained to the top and bottom of the scroll view
    addConstraintToView(scrollView, targetAttribute: topAttribute, fromContentViewAttribute: topAttribute)
    addConstraintToView(scrollView, targetAttribute: bottomAttribute, fromContentViewAttribute: bottomAttribute)
    
    // the content view is constrained to the left and right of the view itself (not its scrollview!)
    addConstraintToView(self, targetAttribute: leadingAttribute, fromContentViewAttribute: leadingAttribute)
    addConstraintToView(self, targetAttribute: trailingAttribute, fromContentViewAttribute: trailingAttribute)
  }
  
  private func addConstraintToView(targetView: UIView, targetAttribute: NSLayoutAttribute, fromContentViewAttribute sourceAttribute: NSLayoutAttribute) {
