SebastianBoldt / Jelly

🌊 - Jelly is a library for animated, non-interactive & interactive viewcontroller transitions and presentations with the focus on a simple and yet flexible API.
http://www.sebastianboldt.com/
MIT License
2.45k stars 121 forks source link

DirectionDismiss is not working #82

Open yongxuean opened 3 years ago

yongxuean commented 3 years ago

I want it to disappear from the left, not from the bottom

class BasePresentationController: UIViewController {

static func presentFromLeftToRight<T: BasePresentationController>(on hostViewController: UIViewController, returnType: T.Type) -> T? {
    let nibName = self.className.replacingOccurrences(of: "ViewController", with: "").replacingOccurrences(of: "Controller", with: "")
    if let presentedVC = UIStoryboard(name: nibName, bundle: nil).instantiateInitialViewController() as? BaseNavigationController {
        guard let vc = presentedVC.viewControllers.first as? T else { return nil }
        let uiConfiguration = PresentationUIConfiguration(backgroundStyle: .dimmed(alpha: 0.7), isTapBackgroundToDismissEnabled: true)
        let alignment = PresentationAlignment(vertical: .center, horizontal: .left)
        let size = PresentationSize(width: .custom(value: 243), height: .fullscreen)
        let presentation = CoverPresentation(directionShow: .left, directionDismiss: .left, uiConfiguration: uiConfiguration, size: size, alignment: alignment)
        let animator = Animator(presentation: presentation)
        animator.prepare(presentedViewController: presentedVC)
        hostViewController.present(presentedVC, animated: true, completion: nil)
        return vc
    } else {
        guard let presentedVC = UIStoryboard(name: nibName, bundle: nil).instantiateInitialViewController() as? T else { return nil }
        let uiConfiguration = PresentationUIConfiguration(backgroundStyle: .dimmed(alpha: 0.7), isTapBackgroundToDismissEnabled: true)
        let alignment = PresentationAlignment(vertical: .center, horizontal: .left)
        let size = PresentationSize(width: .custom(value: 243), height: .fullscreen)
        let presentation = CoverPresentation(directionShow: .left, directionDismiss: .left, uiConfiguration: uiConfiguration, size: size, alignment: alignment)
        let animator = Animator(presentation: presentation)
        animator.prepare(presentedViewController: presentedVC)
        hostViewController.present(presentedVC, animated: true, completion: nil)
        return presentedVC
    }
}

}