                     return
                 }
                 let point = (change![.newKey]! as AnyObject).cgPointValue!
-                let topOffset = direction == .horizontal ? point.x + defaultContentInset.left : point.y + defaultContentInset.top                
+                let topOffset = direction == .horizontal ? point.x + defaultContentInset.left : point.y + defaultContentInset.top
+                        print("TOP topOffset: \(topOffset)")
                 switch topOffset {
                 case 0 where state != .loading:
                     state = .none

        scrollView?.removeObserver(self, forKeyPath: "contentOffset", context: &KVOContext)
        scrollView?.removeObserver(self, forKeyPath: "contentInset", context: &KVOContext)
    }

    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
        if context == &KVOContext {
            if keyPath == "contentOffset" {


class PullToRefresher: NSObject {
    func containerFrame(scrollView: UIScrollView) -> CGRect{
        let horizontalFrame = CGRect(x: -defaultDistanceToTrigger + animatorOffset.horizontal, y: animatorOffset.vertical, width: defaultDistanceToTrigger, height: scrollView.frame.height)
        let verticalFrame = CGRect(x: 0 + animatorOffset.horizontal, y: -defaultDistanceToTrigger + animatorOffset.vertical, width: scrollView.frame.width, height: defaultDistanceToTrigger)
        return direction == .horizontal ? horizontalFrame : verticalFrame
    }
    
    weak var scrollView: UIScrollView? {
        willSet {
            removeScrollViewObserving(scrollView)
