         }
     }
 
-    var rightView: UIView? {
+    public var rightView: UIView? {
         didSet {
             if let oldValue = oldValue {
                 oldValue.removeFromSuperview()

import UIKit
import SnapKit

class SwipeToRevealView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        loadSubviews()
        setupLayout()


extension SwipeToRevealView: UIGestureRecognizerDelegate {

    public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer,
                           shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
        return true
    }

    override public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        guard let pgr = gestureRecognizer as? UIPanGestureRecognizer else { fatalError() }
        let velocity = pgr.velocity(in: self)
        return fabs(velocity.x) > fabs(velocity.y)
