diff --git a/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift b/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift index 2df2050f..fcd00beb 100644 --- a/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift +++ b/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift @@ -1045,6 +1045,7 @@ class AdaptiveModalManager: NSObject { ); }(); + self.modalAnimator?.stopAnimation(true); self.modalAnimator = animator; animator.addAnimations { @@ -1064,10 +1065,12 @@ class AdaptiveModalManager: NSObject { }; animator.addCompletion { _ in + self.endDisplayLink(); self.modalAnimator = nil; }; - + animator.startAnimation(); + self.startDisplayLink(); }; @objc private func onDragPanGesture(_ sender: UIPanGestureRecognizer) { @@ -1095,17 +1098,15 @@ class AdaptiveModalManager: NSObject { let gestureFinalPointRaw = self.gestureFinalPoint ?? gesturePoint; let gestureFinalPoint = CGPoint( - x: gestureFinalPointRaw.x - self.gestureOffset!.x, - y: gestureFinalPointRaw.y - self.gestureOffset!.y + x: gestureFinalPointRaw.x - (self.gestureOffset?.x ?? 0), + y: gestureFinalPointRaw.y - (self.gestureOffset?.y ?? 0) ); self.snapToClosestSnapPoint(forPoint: gestureFinalPoint) { - self.endDisplayLink(); self.notifyOnModalDidSnap(); }; self.clearGestureValues(); - self.startDisplayLink(); default: break; diff --git a/experiments/swift-programmatic-modal/Test/RNIDraggableTestViewController.swift b/experiments/swift-programmatic-modal/Test/RNIDraggableTestViewController.swift index e54f422f..a101f86f 100644 --- a/experiments/swift-programmatic-modal/Test/RNIDraggableTestViewController.swift +++ b/experiments/swift-programmatic-modal/Test/RNIDraggableTestViewController.swift @@ -65,35 +65,12 @@ class RNIDraggableTestViewController : UIViewController { return view; }(); - lazy var dummyBackgroundView: UIView = { - let view = UIView(); - - let imageView = UIImageView( - image: UIImage(named: "DummyBackgroundImage") - ); - - imageView.contentMode = .scaleAspectFill; - - view.addSubview(imageView); - - imageView.translatesAutoresizingMaskIntoConstraints = false; - - NSLayoutConstraint.activate([ - imageView.topAnchor.constraint(equalTo: view.topAnchor), - imageView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - imageView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - imageView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - ]); - - return view; - }(); - override func viewDidLoad() { self.view.backgroundColor = .white; let dummyBackgroundView: UIView = { let imageView = UIImageView( - image: UIImage(named: "DummyBackgroundImage") + image: UIImage(named: "DummyBackgroundImage3") ); imageView.contentMode = .scaleAspectFill; diff --git a/experiments/swift-programmatic-modal/swift-programmatic-modal/Assets.xcassets/DummyBackgroundImage3.imageset/Contents.json b/experiments/swift-programmatic-modal/swift-programmatic-modal/Assets.xcassets/DummyBackgroundImage3.imageset/Contents.json new file mode 100644 index 00000000..0aea5ae1 --- /dev/null +++ b/experiments/swift-programmatic-modal/swift-programmatic-modal/Assets.xcassets/DummyBackgroundImage3.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "DummyBackgroundImage3 1.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/experiments/swift-programmatic-modal/swift-programmatic-modal/Assets.xcassets/DummyBackgroundImage3.imageset/DummyBackgroundImage3 1.png b/experiments/swift-programmatic-modal/swift-programmatic-modal/Assets.xcassets/DummyBackgroundImage3.imageset/DummyBackgroundImage3 1.png new file mode 100644 index 00000000..9e293afe Binary files /dev/null and b/experiments/swift-programmatic-modal/swift-programmatic-modal/Assets.xcassets/DummyBackgroundImage3.imageset/DummyBackgroundImage3 1.png differ