Slide 1

Slide 1 text

Physics based UI for Fun and Profit

Slide 2

Slide 2 text

Overview ▪ Material Design guidelines around motion ▪ Predefined and Dynamic Animations ▪ How a physics system complements Material Design ▪ Brief detour into physics ▪ Rebound Library Walk thru ▪ Comparison of Rebound and Android SDK Animation Techniques ▪ Physics animation techniques

Slide 3

Slide 3 text

Material Design

Slide 4

Slide 4 text

Authentic Motion

Slide 5

Slide 5 text

Consistent choreography

Slide 6

Slide 6 text

Delightful Details

Slide 7

Slide 7 text

Predefined vs Dynamic

Slide 8

Slide 8 text

Predefined Animations

Slide 9

Slide 9 text

Time Driven | Imperative

Slide 10

Slide 10 text

Interpolators can provide realistic feeling curves

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Discrete user interactions

Slide 13

Slide 13 text

Transitions

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Dynamic Animations

Slide 16

Slide 16 text

Goal Driven | Declarative

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Continuous user interactions

Slide 19

Slide 19 text

Retargetable

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Physics Deterministic

Slide 22

Slide 22 text

A Physics system complements Material Design ▪ Authentic motion with a declarative programming model ▪ Consistent Choreography ▪ Delightful to the user

Slide 23

Slide 23 text

Delightful Details

Slide 24

Slide 24 text

Brief Detour into Physics

Slide 25

Slide 25 text

Newton’s Laws of Motion

Slide 26

Slide 26 text

Inertia

Slide 27

Slide 27 text

f = ma

Slide 28

Slide 28 text

For every action there is an equal and opposite reaction.

Slide 29

Slide 29 text

Hooke’s Law

Slide 30

Slide 30 text

f = -kx

Slide 31

Slide 31 text

http://gafferongames.com/game-physics/spring-physics

Slide 32

Slide 32 text

Rebound

Slide 33

Slide 33 text

A simple library that accurately models spring dynamics for the purpose of driving physical animations.

Slide 34

Slide 34 text

Born out of prototyping efforts for Facebook Home

Slide 35

Slide 35 text

Brief trip down memory lane...

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Design Goals ▪ Not a replacement for a full physics engine ▪ Lightweight and cheap to integrate ▪ Not opinionated about rendering ▪ Low level building block to construct higher level components from

Slide 40

Slide 40 text

More interesting as a pattern than as a framework * * but it’s a not a bad implementation of the pattern

Slide 41

Slide 41 text

What can it help you build? ▪ delightful transitions ▪ toggles ▪ pagers ▪ scrollers ▪ Anything that involves goal driven animation with inertia…

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

Hello World

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Core API ▪ SpringSystem ▪ Spring ▪ Listeners ▪ Utilities

Slide 46

Slide 46 text

SpringSystem ▪ maintains a set of springs ▪ provides hooks for acting before and after each integration ▪ Is driven by a looper until equilibrium is achieved on all the springs it maintains ▪ allows synchronous and time choreographed simulation

Slide 47

Slide 47 text

Spring ▪ A model of the motion of a spring ▪ accepts listeners and notifies of lifecycle events ▪ accepts a configuration object for defining spring tension and friction ▪ accepts a velocity and/or end value

Slide 48

Slide 48 text

Listeners SpringListener ▪ onSpringActivate ▪ onSpringUpdate ▪ onSpringAtRest ▪ onSpringEndStateChange SpringSystemListener ▪ onBeforeIntegrate ▪ onAfterIntegrate

Slide 49

Slide 49 text

Architecture

Slide 50

Slide 50 text

SpringSystem Spring SpringSystemListener SpringListener creates/observes observes observes SpringLooper drives Concrete Classes SteppingLooper SynchronousLooper ChoreographerAndroidSpringLooper LegacyAndroidSpringLooper Methods onSpringActivate onSpringUpdate onSpringAtRest onSpringEndStateChange Methods onBeforeIntegrate onAfterIntegrate SpringConfig SpringConfigRegistry holds has Methods setCurrentValue setEndValue setVelocity

Slide 51

Slide 51 text

Utilities ▪ SpringConfig provides tension and friction values to a spring ▪ SpringUtil provides helper functions for clamping and interpolating values in ranges ▪ ChoreographerCompat polyfills the Choreographer timing API on pre-JellyBean

Slide 52

Slide 52 text

More Utilities ▪ SpringConfiguratorView provides an Android View for live tuning your SpringConfigs while the app is running ▪ AnimationQueue and SpringChain can help you create cascading effects

Slide 53

Slide 53 text

SpringConfiguratorView SpringChain

Slide 54

Slide 54 text

Comparative Example

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

Tips & Tricks

Slide 62

Slide 62 text

Use 0 to 1 toggle Springs and interpolate

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

Use springs to indirectly manipulate views

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

Use a common Spring to converge animations

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

Use SpringSystemListener to apply constraints

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

Origami Integration

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

Future Plans ▪ Release more components built on Rebound ▪ Iterate and Improve integration with Origami ▪ Create more examples of Rebound physics complementing Material design patterns

Slide 74

Slide 74 text

Get the Code dependencies { compile 'com.facebook.rebound:rebound:0.3.7' } http://facebook.github.io/rebound or

Slide 75

Slide 75 text

There’s a JavaScript version too! npm install rebound https://github.com/facebook/rebound-js or

Slide 76

Slide 76 text

Thank you! @will_bailey [email protected]