Slide 1

Slide 1 text

An introduction to Material Motion by @featherless - engineering lead // April 10, 2017

Slide 2

Slide 2 text

About @featherless Software designer on the Material Design team I build shared libraries for Google’s iOS apps and the open source community

Slide 3

Slide 3 text

About @featherless Software designer on the Material Design team Previously: Facebook iOS app 2009 Nimbus iOS libraries 2011 Google Maps iOS app 2012 Material Components iOS libraries at Google 2013, 2014-2015

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

productive inspiring

Slide 6

Slide 6 text

Material Motion

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

engineering For considerations on motion design, visit our spec at material.io/guidelines/motion/

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

hard

Slide 11

Slide 11 text

hard

Slide 12

Slide 12 text

hard

Slide 13

Slide 13 text

hard

Slide 14

Slide 14 text

hard

Slide 15

Slide 15 text

hard get right

Slide 16

Slide 16 text

Challenges

Slide 17

Slide 17 text

Challenges

Slide 18

Slide 18 text

Jank is any stuttering, juddering or just plain halting that users see when an app isn't keeping up with the refresh rate. - jankfree.org

Slide 19

Slide 19 text

Challenges

Slide 20

Slide 20 text

Gestural interactions should feed their velocity into animations in a simulation of continuous momentum.

Slide 21

Slide 21 text

Gestural interactions should feed their velocity into animations in a simulation of continuous momentum. - from Facebook Paper’s tech talk youtu.be/OiY1cheLpmI?t=47m30s

Slide 22

Slide 22 text

Challenges

Slide 23

Slide 23 text

Don’t force users to wait for animations to complete before being allowed to take their next action.

Slide 24

Slide 24 text

Challenges

Slide 25

Slide 25 text

Animations don’t generally react well to breakpoints because breakpoints disconnect animations from time.

Slide 26

Slide 26 text

Animations don’t generally react well to breakpoints because breakpoints disconnect animations from time. We need real-time tooling designed specifically for motion.

Slide 27

Slide 27 text

Challenges

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Intro to Material Motion

Slide 30

Slide 30 text

Intro to Material Motion How to make things move

Slide 31

Slide 31 text

Intro to Material Motion How to make things move How to build transitions

Slide 32

Slide 32 text

Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 33

Slide 33 text

Common implementations of motion

Slide 34

Slide 34 text

one-off animation code scattered in view controllers Common implementations of motion

Slide 35

Slide 35 text

Interactions Constraints Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 36

Slide 36 text

Interactions Constraints Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 37

Slide 37 text

How to make things move

Slide 38

Slide 38 text

How to make things move An object that conforms to the Interaction protocol.

Slide 39

Slide 39 text

How to make things move

Slide 40

Slide 40 text

Gestural interactions How to make things move

Slide 41

Slide 41 text

How to make things move Gestural interactions Animated interactions

Slide 42

Slide 42 text

How to make things move Gestural interactions Animated interactions Compositional interactions

Slide 43

Slide 43 text

How to make things move Gestural

Slide 44

Slide 44 text

let draggable = Draggable() let rotatable = Rotatable() let scalable = Scalable() How to make things move Gestural

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

// Interaction: Draggable let view = UIView() How to make things move

Slide 47

Slide 47 text

// Interaction: Draggable let view = UIView() let runtime = MotionRuntime() How to make things move

Slide 48

Slide 48 text

// Interaction: Draggable let view = UIView() let runtime = MotionRuntime() let draggable = Draggable() How to make things move

Slide 49

Slide 49 text

// Interaction: Draggable let view = UIView() let runtime = MotionRuntime() let draggable = Draggable() runtime.add(draggable, to: view) How to make things move

Slide 50

Slide 50 text

// Interaction: Draggable let view = UIView() let runtime = MotionRuntime() runtime.add(Rotatable(), to: view) How to make things move

Slide 51

Slide 51 text

// Interaction: Draggable let view = UIView() let runtime = MotionRuntime() runtime.add(Scalable(), to: view) How to make things move

Slide 52

Slide 52 text

How to make things move

Slide 53

Slide 53 text

Use Core Animation. How to make things move

Slide 54

Slide 54 text

How to make things move Use Core Animation. Generic Interaction types.

Slide 55

Slide 55 text

Use Core Animation. Generic Interaction types. let spring = Spring() How to make things move

Slide 56

Slide 56 text

Use Core Animation. Generic Interaction types. let spring = Spring() let spring = Spring() How to make things move

Slide 57

Slide 57 text

How to make things move Use Core Animation. Generic Interaction types. let spring = Spring() let spring = Spring() let tween = Tween() let tween = Tween()

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

// Interaction: Spring let view = UIView() let runtime = MotionRuntime() How to make things move

Slide 60

Slide 60 text

// Interaction: Spring let view = UIView() let runtime = MotionRuntime() let spring = Spring() How to make things move

Slide 61

Slide 61 text

// Interaction: Spring let view = UIView() let runtime = MotionRuntime() let spring = Spring() runtime.add(spring, How to make things move

Slide 62

Slide 62 text

// Interaction: Spring let view = UIView() let runtime = MotionRuntime() let spring = Spring() runtime.add(spring, to: runtime.get(view).position) How to make things move

Slide 63

Slide 63 text

// Interaction: Spring let view = UIView() let runtime = MotionRuntime() let spring = Spring() runtime.add(spring, to: runtime.get(view).position) How to make things move

Slide 64

Slide 64 text

Reactive programming

Slide 65

Slide 65 text

reactive Reactive programming

Slide 66

Slide 66 text

Reactive programming view: UIView view

Slide 67

Slide 67 text

Reactive programming view: UIView position: ReactiveProperty position 50, 50 view

Slide 68

Slide 68 text

Reactive programming view: UIView position: ReactiveProperty let subscription = position .subscribe { value in print(value) } position 50, 50 view Subscription

Slide 69

Slide 69 text

Reactive programming view: UIView position: ReactiveProperty let subscription = position .subscribe { value in print(value) } Subscription Console 50, 50 position 50, 50 view

Slide 70

Slide 70 text

Reactive programming view: UIView position: ReactiveProperty let subscription = position .subscribe { value in print(value) } position.value = .init(x: 10, y: 20) Subscription Console 50, 50 10, 20 position 50, 50 view

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

// Interaction: Spring let view = UIView() let runtime = MotionRuntime() let spring = Spring() runtime.add(spring, to: runtime.get(view).position) How to make things move

Slide 73

Slide 73 text

// Interaction: Spring let view = UIView() let runtime = MotionRuntime() let spring = Spring() runtime.add(spring, to: runtime.get(view).position) spring.destination How to make things move reactive property

Slide 74

Slide 74 text

// Interaction: Spring let view = UIView() let runtime = MotionRuntime() let spring = Spring() runtime.add(spring, to: runtime.get(view).position) spring.destination.value = CGPoint(x: 75, y: 50) How to make things move

Slide 75

Slide 75 text

Reactive programming connect

Slide 76

Slide 76 text

Reactive programming runtime.add(spring, to: property) Spring() property

Slide 77

Slide 77 text

Reactive programming Spring system value runtime.add(spring, to: property) property

Slide 78

Slide 78 text

Reactive programming view runtime.add(Draggable(), to: view) Draggable()

Slide 79

Slide 79 text

Reactive programming Pan Gesture translation position view runtime.add(Draggable(), to: view)

Slide 80

Slide 80 text

Reactive programming composable

Slide 81

Slide 81 text

Reactive programming Draggable + Rotatable + Scalable =

Slide 82

Slide 82 text

Reactive programming Draggable + Rotatable + Scalable = DirectlyManipulable

Slide 83

Slide 83 text

Reactive programming Draggable + Rotatable + Scalable = DirectlyManipulable Draggable + Spring =

Slide 84

Slide 84 text

Reactive programming Draggable + Rotatable + Scalable = DirectlyManipulable Draggable + Spring = Tossable

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

// Interaction: Tossable let view = UIView() let runtime = MotionRuntime() How to make things move

Slide 87

Slide 87 text

// Interaction: Tossable let view = UIView() let runtime = MotionRuntime() let tossable = Tossable() How to make things move

Slide 88

Slide 88 text

// Interaction: Tossable let view = UIView() let runtime = MotionRuntime() let tossable = Tossable() runtime.add(tossable, to: view) How to make things move

Slide 89

Slide 89 text

// Interaction: Tossable let view = UIView() let runtime = MotionRuntime() let tossable = Tossable() runtime.add(tossable, to: view) // Under the hood: How to make things move

Slide 90

Slide 90 text

// Interaction: Tossable let view = UIView() let runtime = MotionRuntime() let tossable = Tossable() runtime.add(tossable, to: view) // Under the hood: // runtime.add(spring, to: view.position) // runtime.add(draggable, to: view) How to make things move

Slide 91

Slide 91 text

// Interaction: Tossable let view = UIView() let runtime = MotionRuntime() let tossable = Tossable() runtime.add(tossable, to: view) // Under the hood: // runtime.connect(draggable.finalVelocity, to: spring.initialVelocity) // runtime.add(spring, to: view.position) // runtime.add(draggable, to: view) How to make things move

Slide 92

Slide 92 text

Interactions Constraints Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 93

Slide 93 text

Reactive programming Pan Gesture translation position view

Slide 94

Slide 94 text

Reactive programming Pan Gesture translation position view constraint xLocked

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

// Customizing interactions let draggable = Draggable() runtime.add(draggable, to: mochiView) How to make things move

Slide 97

Slide 97 text

// Customizing interactions - Constraints let draggable = Draggable() runtime.add(draggable, to: mochiView, constraints: { return $0.xLocked(to: 100) }) How to make things move

Slide 98

Slide 98 text

// Customizing interactions - Constraints let draggable = Draggable() runtime.add(draggable, to: mochiView, constraints: { return $0.xLocked(to: 100) .rubberBanded(below: -50, above: 50, maxLength: 25) }) How to make things move

Slide 99

Slide 99 text

Intro to Material Motion How to make things move How to build transitions Closing thoughts Short summary:

Slide 100

Slide 100 text

Intro to Material Motion How to make things move How to build transitions Closing thoughts Short summary: ●

Slide 101

Slide 101 text

Intro to Material Motion How to make things move How to build transitions Closing thoughts Short summary: ● ●

Slide 102

Slide 102 text

Intro to Material Motion How to make things move How to build transitions Closing thoughts Short summary: ● ● ●

Slide 103

Slide 103 text

Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 104

Slide 104 text

Intro to Material Motion How to make things move How to build transitions Closing thoughts Using custom transitions Creating a transition

Slide 105

Slide 105 text

Intro to Material Motion How to make things move How to build transitions Closing thoughts Using custom transitions Creating a transition

Slide 106

Slide 106 text

// Custom transitions viewController How to build transitions

Slide 107

Slide 107 text

// Custom transitions viewController.transitionController transitionController How to build transitions

Slide 108

Slide 108 text

// Custom transitions viewController.transitionController.transition = PushBackTransition.self How to build transitions PushBackTransition

Slide 109

Slide 109 text

// Custom transitions viewController.transitionController.transition = PushBackTransition.self present(viewController, animated: true) How to build transitions

Slide 110

Slide 110 text

// Custom transitions viewController.transitionController.transition = PushBackTransition.self present(viewController, animated: true) dismiss(animated: true) How to build transitions

Slide 111

Slide 111 text

Intro to Material Motion How to make things move How to build transitions Closing thoughts Using custom transitions Creating a transition

Slide 112

Slide 112 text

// Building a transition class PushBackTransition: Transition { } How to build transitions

Slide 113

Slide 113 text

How to build transitions // Building a transition class PushBackTransition: Transition { func willBegin(ctx: TransitionContext, runtime: MotionRuntime) { } }

Slide 114

Slide 114 text

How to build transitions // Building a transition class PushBackTransition: Transition { func willBegin(ctx: TransitionContext, runtime: MotionRuntime) { } }

Slide 115

Slide 115 text

How to build transitions // Building a transition class PushBackTransition: Transition { func willBegin(ctx: TransitionContext, runtime: MotionRuntime) { } } ● ● ● ●

Slide 116

Slide 116 text

How to build transitions // Building a transition class PushBackTransition: Transition { func willBegin(ctx: TransitionContext, runtime: MotionRuntime) { let offscreen = ctx.height + ctx.fore.height / 2 let onscreen = ctx.center.y } }

Slide 117

Slide 117 text

How to build transitions // Building a transition class PushBackTransition: Transition { func willBegin(ctx: TransitionContext, runtime: MotionRuntime) { let offscreen = ctx.height + ctx.fore.height / 2 let onscreen = ctx.center.y } } fore back fore

Slide 118

Slide 118 text

How to build transitions // Building a transition class PushBackTransition: Transition { func willBegin(ctx: TransitionContext, runtime: MotionRuntime) { let offscreen = ctx.height + ctx.fore.height / 2 let onscreen = ctx.center.y } } fore back back fore back fore

Slide 119

Slide 119 text

How to build transitions // Building a transition class PushBackTransition: Transition { func willBegin(ctx: TransitionContext, runtime: MotionRuntime) { let offscreen = ctx.height + ctx.fore.height / 2 let onscreen = ctx.center.y runtime.add(TransitionSpring(back: offscreen, fore: onscreen, direction: ctx.direction) to: ctx.fore.positionY) } }

Slide 120

Slide 120 text

How to build transitions // Building a transition class PushBackTransition: Transition { func willBegin(ctx: TransitionContext, runtime: MotionRuntime) { let offscreen = ctx.height + ctx.fore.height / 2 let onscreen = ctx.center.y runtime.add(TransitionSpring(back: offscreen, fore: onscreen, direction: ctx.direction) to: ctx.fore.positionY) } } back fore

Slide 121

Slide 121 text

How to build transitions // Building a transition class PushBackTransition: Transition { func willBegin(ctx: TransitionContext, runtime: MotionRuntime) { let offscreen = ctx.height + ctx.fore.height / 2 let onscreen = ctx.center.y runtime.add(TransitionSpring(back: offscreen, fore: onscreen, direction: ctx.direction) to: ctx.fore.positionY) runtime.add(TransitionSpring(back: 1, fore: 0.95, direction: ctx.direction), to: ctx.back.scale) } }

Slide 122

Slide 122 text

// Building a transition class PushBackTransition: Transition { func willBegin(ctx: TransitionContext, runtime: MotionRuntime) { let offscreen = ctx.height + ctx.fore.height / 2 let onscreen = ctx.center.y runtime.add(TransitionSpring(back: offscreen, fore: onscreen, direction: ctx.direction) to: ctx.fore.positionY) runtime.add(TransitionSpring(back: 1, fore: 0.95, direction: ctx.direction), to: ctx.back.scale) } } How to build transitions

Slide 123

Slide 123 text

Reactive programming

Slide 124

Slide 124 text

Reactive programming reversible

Slide 125

Slide 125 text

Reactive programming reversible

Slide 126

Slide 126 text

Reactive programming position view

Slide 127

Slide 127 text

Reactive programming value position view Spring

Slide 128

Slide 128 text

Reactive programming value position view Spring destination

Slide 129

Slide 129 text

Reactive programming value position view Spring destination fore value

Slide 130

Slide 130 text

Reactive programming value position view Spring destination back value

Slide 131

Slide 131 text

Reactive programming value position view Spring destination direction

Slide 132

Slide 132 text

Reactive programming value position view Spring destination direction rewrite back fore

Slide 133

Slide 133 text

Reactive programming value position view Spring destination direction rewrite fore

Slide 134

Slide 134 text

Reactive programming value position view Spring destination direction rewrite back

Slide 135

Slide 135 text

Summary: Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 136

Slide 136 text

Summary: ● Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 137

Slide 137 text

Intro to Material Motion How to make things move How to build transitions Closing thoughts Summary: ● ● reactive

Slide 138

Slide 138 text

Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 139

Slide 139 text

responsive Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 140

Slide 140 text

responsive ● ● ● ● ● Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 141

Slide 141 text

responsive ● ● ● ● ● github.com/material-motion Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 142

Slide 142 text

responsive ● ● ● ● ● github.com/material-motion discord.gg/ZJyGXza Intro to Material Motion How to make things move How to build transitions Closing thoughts

Slide 143

Slide 143 text

github.com/material-motion discord.gg/ZJyGXza

Slide 144

Slide 144 text

Some quick background on Core Animation (CA) Core Animation

Slide 145

Slide 145 text

Some quick background on Core Animation (CA) ● CA animations occur on the render server. Core Animation

Slide 146

Slide 146 text

Some quick background on Core Animation (CA) ● CA animations occur on the render server. ● The render server is independent from your app’s main thread. Core Animation

Slide 147

Slide 147 text

Some quick background on Core Animation (CA) ● CA animations occur on the render server. ● The render server is independent from your app’s main thread. This means CA animations aren’t subject to main-thread jank. Core Animation

Slide 148

Slide 148 text

Core Animation Some quick background on Core Animation (CA) ● CA animations occur on the render server. ● The render server is independent from your app’s main thread. This means CA animations aren’t subject to main-thread jank. Third-party animation libraries like Facebook’s POP operate on the main thread, which is why POP is often used hand-in-hand with AsyncDisplayKit.