Material Motion Exploring solutions that will empower creators with the tools needed to describe and implement rich, interactive motion on any platform. Edit this page · History
GestureRecognizer · $._filter whenRecognitionStateIs
whenRecognitionStateIsAnyOf
Status Interface level Implementation level Library
Stable as of February 21, 2016 L2: Interaction creator L3: Stream creator material-motion
platformsrctests
iOS (Swift) View
whenRecognitionStateIs
upstream (GestureRecognizer)
(GestureRecognizer) downstream

whenRecognitionStateIs specification

This is the engineering specification for the MotionObservable operator whenRecognitionStateIs that operates on GestureRecognizer value types.

Overview

Only invoke next when the gesture recognizer’s state matches the provided states.

Example usage:

gestureSource(gesture).whenRecognitionStateIs(began)

MVP

Expose whenRecognitionStateIs API

Should delegate to _filter. This API should only be available for streams emitting GestureRecognizer values.

The output of this operator should be a GestureRecognizer.

extension MotionObservable where T: GestureRecognizer {
  public func whenRecognitionStateIs(state: GestureRecognizerState) -> MotionObservable<T> {
    return _filter { value in
      return value.state == state
    }
  }