1 //  Copyright (c) 2018, Applidium. All rights reserved
2 //  UIScrollViiew+Utils.swift
3 //  Pods
4 //
5 //  Created by Gaétan Zanella on 28/11/2018.
6 //
7 
8 import UIKit
9 
10 extension UIScrollView {
11 
12     var scrollsUp: Bool {
13         return panGestureRecognizer.yDirection == .up
14     }
15 
16     var isContentOriginInBounds: Bool {
17         topOffsetInContent <= 0.0
18     }
19 
20     var topOffsetInContent: CGFloat {
21         contentOffset.y + oc_adjustedContentInset.top
22     }
23 
scrollToTopnull24     func scrollToTop() {
25         contentOffset.y = -oc_adjustedContentInset.top
26     }
27 }
28 
29 
30 extension UIScrollView {
31 
32     var oc_adjustedContentInset: UIEdgeInsets {
33         if #available(iOS 11.0, *) {
34             return self.adjustedContentInset
35         } else {
36             // Fallback on earlier versions
37             return self.contentInset
38         }
39     }
40 }
41