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
$._map normalizedBy
Status Interface level Implementation level Library
Stable as of March 30, 2016 L2: Interaction creator L3: Stream creator material-motion
UpdatesCurrent StatusInitiation dateCompletion date
First introduced Stable March 30, 2017
platformsrctests
Android View
iOS (Swift) View View
normalizedBy
upstream (number | Point2D)
amount (number | Point2D)
(number | Point2D) downstream

normalizedBy specification

This is the engineering specification for the MotionObservable operator: normalizedBy.

Overview

normalizedBy emits the result of dividing the incoming scalar values by a given amount.

Example usage:

stream.normalized(by: 50)

upstream  amount  |  downstream
20        50      |  0.4
40        50      |  0.8
80        50      |  1.6
stream.normalized(by: CGPoint(x: 100, y: 10))

upstream  amount   |  downstream
10, 20    100, 10  |  0.1, 2
50, 2     100, 10  |  0.5, 0.2
20, -5    100, 10  |  0.2, -0.5

MVP

Expose a scalar normalizedBy operator API

Use _map to implement the operator. Accept a number value. Emit the result of incoming / value.

class MotionObservable {
  public func normalized(by value: number) -> MotionObservable<number>
}

Expose a point normalizedBy operator API

Use _map to implement the operator. Accept a point value. Emit the result of incoming.x / value.x, incoming.y / value.y.

class MotionObservable {
  public func normalized(by value: Point2D) -> MotionObservable<Point2D>
}