 import UIKit
 import SpriteKit
 
+private enum RefreshState {
+    case normal
+    case pulling
+    case loading
+}
+
 protocol RainyRefreshControlDelegate {
-    func pullToRefreshDidTrigger(_ view: RainyRefreshControl) -> ()
+    func pullToRefreshDidTrigger(_ view: RainyRefreshControl)
 }
 
 final class RainyRefreshControl: UIView {
 
-    private enum RefreshState {
-        case normal
-        case pulling
-        case loading
-    }
-    
+    public var thresholdValue: CGFloat = 100.0
+    public var delegate: RainyRefreshControlDelegate?
+
     private var state: RefreshState = .normal {
         didSet {
             switch state {

            delegate?.pullToRefreshDidTrigger(self)
        }
    }
    
    public func refreshScrollViewDataSourceDidFinishedLoading(_ scrollView: UIScrollView) {
        umbrellaView.setButtonState(state: .closed, animated: true)
        DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {

            offset = min(offset, thresholdValue)
            scrollView.contentInset = UIEdgeInsetsMake(offset, 0.0, 0.0, 0.0)
            UIView.commitAnimations()

        } else if scrollView.isDragging {
            let loading = false
            if state == .pulling && scrollView.contentOffset.y > -thresholdValue && scrollView.contentOffset.y < 0.0 && !loading {
                state = .normal
            } else if state == .normal && scrollView.contentOffset.y < -thresholdValue && !loading {
                state = .pulling
            }
        }

    }

    public func refreshScrollViewDidEndDragging(_ scrollView: UIScrollView) {
        let loading = false
        if scrollView.contentOffset.y <= -thresholdValue && !loading {
