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

whenRecognitionStateIsAnyOf specification

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

Overview

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

Example usage:

gestureSource(gesture).whenRecognitionStateIsAnyOf([began, changed])

MVP

Expose whenRecognitionStateIsAnyOf 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 whenRecognitionStateIsAnyOf(states: [UIGestureRecognizerState]) -> MotionObservable<T> {
    return _filter { value in
      return states.contains(value.state)
    }
  }