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
runtime · interactions MotionRuntime.interactions
Status Interface level Implementation level Library
Stable as of April 24, 2017 L1: App creator L4: Runtime engineering material-motion
UpdatesCurrent StatusInitiation dateCompletion date
Introduced spec. Stable April 24, 2017
platformsrctests
Android View
iOS (Swift) View

MotionRuntime.interactions specification

This is the engineering specification for the MotionRuntime’s interactions API.

Overview

This API retrieves interactions of a specific type associated with a given target via the .add API.

let draggables = runtime.interactions(ofType: Draggable.self, for: view)

MVP

Expose an interactions API

The API should be generic on the Interaction type and accept a class and target.

class MotionRuntime {
  public func interactions<I>(ofType: I.Type, for target: I.Target) -> [I] where I: Interaction
}

Cache interactions associated with targets in runtime.add

Each time an interaction is added to a target, cache that association in an internal map of targets to interactions.

Return all interactions of the desired type for the given target.

Return the list of interactions matching the desired type that were associated with the given target.