 }
 
 final class NestedScrollViewVC: UIViewController {
-    private lazy var outerScrollView: UIScrollView = {
-        let outer = UIScrollView()
-        outer.delegate = self
-        outer.backgroundColor = .systemRed
+    private lazy var outerScrollView: OuterScrollView = {
+        let outer = OuterScrollView()
+        outer.backgroundColor = .systemGray
         return outer
     }()
     
-    private lazy var nestedUIScrollView: UIScrollView = {
-        let nested = UIScrollView()
-        nested.delegate = self
+    private lazy var nestedScrollView: NestedScrollView = {
+        let nested = NestedScrollView()
         nested.backgroundColor = .systemBlue
         return nested
     }()

        view.backgroundColor = .white
        
        view.addSubview(outerScrollView)
        outerScrollView.contentSize = CGSize(width: view.frame.width - 20, height: 5000)
        outerScrollView.frame = CGRect(x: 10, y: 50, width: view.frame.width - 20, height: view.frame.height - 88)
        
        outerScrollView.addSubview(nestedUIScrollView)
        nestedUIScrollView.contentSize = CGSize(width: view.frame.width - 40, height: 5000)
        nestedUIScrollView.frame = CGRect(x: 10, y: 400, width: view.frame.width - 40, height: view.frame.height - 438)
    }
}

extension NestedScrollViewVC: UIScrollViewDelegate {
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        outerScrollView.contentOffset = scrollView.contentOffset
        outerScrollView.panGestureRecognizer.state = scrollView.panGestureRecognizer.state
    }
}

final class OuterScrollView: UIScrollView, UIScrollViewDelegate {
    var outerDeceleration: ScrollingDeceleration?

    }()

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        decelerator.invalidateIfNeeded()
    }
}
