   }
 }
 
+@available(iOS 9.0, *)
 class ModalDialogTransition: SelfDismissingTransition {
 
   required init() {}

    }

    let bounds = ctx.containerView().bounds
    let backPositionY = bounds.maxY + size.height * 3 / 4
    let forePositionY = bounds.midY

    let mainThreadReactive: Bool
    let system: SpringToStream<CGFloat>
    if #available(iOS 9.0, *) {
      mainThreadReactive = false
      system = coreAnimation
    } else {
      mainThreadReactive = true
      system = pop
    }
    let spring = TransitionSpring(back: backPositionY,
                                  fore: forePositionY,
                                  direction: ctx.direction,
                                  threshold: 1,
                                  system: system)

    let reactiveForeLayer = runtime.get(ctx.fore.view.layer)

    for gestureRecognizer in ctx.gestureRecognizers {
      switch gestureRecognizer {
      case let pan as UIPanGestureRecognizer:
        let gesture = runtime.get(pan)

        let dragStream = gesture.translated(from: reactiveForeLayer.position).y()
        runtime.add(dragStream, to: reactiveForeLayer.positionY)

        let velocityStream = gesture.velocityOnReleaseStream().y()
        runtime.add(velocityStream, to: spring.initialVelocity)

        let centerY = ctx.containerView().bounds.height / 2.0
        let positionY = reactiveForeLayer.positionY
        let positionDestination: MotionObservable<TransitionContext.Direction> =
          positionY.threshold(centerY).rewrite([.whenBelow: .forward, .whenAbove: .backward])

        runtime.add(velocityStream
          .thresholdRange(min: -100, max: 100)
          // If one of rewrite's target values is a stream, then all the target values must be
          // streams.
          .rewrite([.whenBelow: createProperty(withInitialValue: .forward).asStream(),
                    .whenWithin: positionDestination,
                    .whenAbove: createProperty(withInitialValue: .backward).asStream()]),
                    to: ctx.direction)

        runtime.enable(spring, whenAtRest: gesture)

      default:
        ()
      }
    }

    runtime.add(spring, to: reactiveForeLayer.positionY)

    if mainThreadReactive {
      let rotation = reactiveForeLayer.positionY
        .rewriteRange(start: spring.backwardDestination,
                      end: spring.forwardDestination,
                      destinationStart: CGFloat(Double.pi / 8),
                      destinationEnd: 0)
      runtime.add(rotation, to: reactiveForeLayer.rotation)
    }

    return [spring]
  }

  static func willPresent(fore: UIViewController, dismisser: ViewControllerDismisser) {

  override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
    super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)

    if #available(iOS 9.0, *) {
      transitionController.transitionType = ModalDialogTransition.self
    } else {
      // Fallback on earlier versions
    }

    modalPresentationStyle = .overCurrentContext
  }
