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 TranslationGestureRecognizer Draggable · translationAddedTo · velocity
Status Library
Stable as of December 4, 2016 gestures
platformsrctests
Android View
iOS View

TranslationGestureRecognizer specification

This is the engineering specification for the TranslationGestureRecognizer object.

Overview

A translation gesture recognizer listens to input events and generates translation events relative to an initial position.

If multiple input events are being received simultaneously — e.g. multiple fingers — then the centroid of the events should be used in all calculations.

MVP

Is a GestureRecognizer

TranslationGestureRecognizer conforms to the GestureRecognizer protocol.

Pseudo-code example:

class TranslationGestureRecognizer: GestureRecognizer {
}

Translation API

Expose an API for reading the current translation of the gesture recognizer in relation to the associated element.

The translation should be expressed in individual components for platform’s available axis of movement. For example, on a touch screen this might be a two-dimensional vector consisting of an x and a y translation.

class TranslationGestureRecognizer {
  func translation() -> Vector

Velocity API

Expose an API for reading the current translation velocity of the input events in relation to the associated element.

The velocity should be expressed in individual components for platform’s available axis of movement. For example, on a touch screen this might be a two-dimensional vector consisting of an x and a y velocity.

TODO: Spec out an implementation for calculating velocity.

class TranslationGestureRecognizer {
  func velocity() -> Vector

Recognition threshold API

Expose an API for setting the translation threshhold that must be passed before this gesture recognizer begins emitting Changed gesture events.

The default value is platform-dependent.

class TranslationGestureRecognizer {
  var recognitionThreshold: Vector