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
Status Interface level Implementation level Library
Stable as of February 21, 2016 L2: Interaction creator L3: Stream creator material-motion
iOS (Swift) View
upstream (GestureRecognizer)
(GestureRecognizer) downstream

whenRecognitionStateIs specification

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


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

Example usage:



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