44
12 Ways to Bounce a Ball A Tour of the Web Animations Ecosystem

12 Ways to Bounce a Ball

Embed Size (px)

Citation preview

Page 1: 12 Ways to Bounce a Ball

12 Ways to Bounce a Ball

A Tour of the Web Animations Ecosystem

Page 2: 12 Ways to Bounce a Ball

Animation by Jovie Brett Bardoles: https://dribbble.com/shots/2159651-Responsive-Material-Design

Page 3: 12 Ways to Bounce a Ball
Page 4: 12 Ways to Bounce a Ball

Comparing Techniques

• Vanilla Javascript • Backbone.js • KnockoutJS • Dojo • Ampersand • AngularJS • Ember.js • React • Vue.js • ...and more

TodoMVC – todomvc.com

Page 5: 12 Ways to Bounce a Ball

https://sparkbox.github.io/bouncy-ball

Page 6: 12 Ways to Bounce a Ball

The 12 Ways• Vanilla Javascript • CSS Animations • Web Animations API • SMIL

• Greensock • Velocity • mo.js • anime.js

• jQuery Animations • P5.js

• D3 • React

Page 7: 12 Ways to Bounce a Ball

More Ways?HTML5 Video

Page 8: 12 Ways to Bounce a Ball

More Ways?Animated Gif

Page 9: 12 Ways to Bounce a Ball

More Ways?WebGL

Page 10: 12 Ways to Bounce a Ball

More Ways?Flash

Page 11: 12 Ways to Bounce a Ball

More Ways?<marquee>

This page is under construction

Watch your step

CAUTION

Page 12: 12 Ways to Bounce a Ball

The 12 Ways• Vanilla Javascript • CSS Animations • Web Animations API • SMIL

• Greensock • Velocity • mo.js • anime.js

• jQuery Animations • P5.js

• D3 • React

Page 13: 12 Ways to Bounce a Ball

The 12 Ways

• Vanilla Javascript • CSS Animations • Web Animations API • SMIL

• Greensock • Velocity • mo.js • anime.js

• jQuery Animations • P5.js

• D3 • React

BROWSER APIS ANIMATION TOOLS

OTHER

Page 14: 12 Ways to Bounce a Ball

Vanilla JavascriptBROWSER APIS

requestAnimationFrame()

"whatever"• Move a Div

• Draw on a Canvas

• Change a CSS property

• Re-draw an SVG

Page 15: 12 Ways to Bounce a Ball

CSS AnimationsBROWSER APIS

Transitions

• Pseudo-classes: :hover, :active, :focus, :checked, :disabled

• Media-queries • Can be triggered by

Javascript

Triggered by user

Page 16: 12 Ways to Bounce a Ball

CSS AnimationsBROWSER APIS

Keyframe Animations

http://bryanbraun.com/2014/05/05/css-transitions-vs-keyframe-animations

Page 17: 12 Ways to Bounce a Ball

SMILBROWSER APIS

<animateTransform> <animateMotion>• Translation • Rotation • Scale • Skew

• Animate along a path (curved or straight)

DEPRECA

TED

Page 18: 12 Ways to Bounce a Ball

Web Animations APIBROWSER APIS

Browser Support: caniuse.com/#feat=web-animation

W3C Status: Working Draft

Polyfill: github.com/web-animations/web-animations-js

Page 19: 12 Ways to Bounce a Ball

GreensockANIMATION TOOLS

• TweenLite

• TimelineLite

• TweenMax

• TimelineMax

Page 20: 12 Ways to Bounce a Ball

VelocityANIMATION TOOLS

http://velocityjs.org

Page 21: 12 Ways to Bounce a Ball

mo.js anime.jsANIMATION TOOLS

&

http://mojs.io/ http://anime-js.com/

Page 22: 12 Ways to Bounce a Ball

jQuery AnimationsOTHER

Page 23: 12 Ways to Bounce a Ball

P5.jsOTHER

https://p5js.org/

Page 24: 12 Ways to Bounce a Ball

D3OTHER

Page 25: 12 Ways to Bounce a Ball

ReactOTHER

https://www.youtube.com/watch?v=QlmaI7x7SYoAnimating in React – Sarah Drasner

Animation Approaches

• React-Motion

• CSS Animations

• Javascript (if you are careful)

Page 26: 12 Ways to Bounce a Ball

The 12 Ways• Vanilla Javascript • CSS Animations • Web Animations API • SMIL

• Greensock • Velocity • mo.js • anime.js

• jQuery Animations • P5.js

• D3 • React

Page 27: 12 Ways to Bounce a Ball

Animation Paradigms

1. Math

2. Physics

3. Flipbook

4. Tweening/Keyframes

Page 28: 12 Ways to Bounce a Ball

Math

y = -0.000484(mod(t + 575, 575 * 2) - 575)^2 + 160

Height

Can you represent position with a mathematical function?

Page 29: 12 Ways to Bounce a Ball

Physics

• 2D • Matter.js

• 3D • Ammo.js • Cannon.js

Physics Engines

Page 30: 12 Ways to Bounce a Ball

PhysicsWrite your own physics

• Time Based Animation (time deltas) • https://www.viget.com/articles/time-based-animation

• Kinematic Formulas (long time deltas) • (there's a great lesson on Khan Academy)

• 5 Minute Physics by David DeSandro • https://www.youtube.com/watch?v=n6FKT-KafRk

Good for low-level techniques: Vanilla Javascript, P5, etc.

Page 31: 12 Ways to Bounce a Ball

Physics

Page 32: 12 Ways to Bounce a Ball

Flipbook

Image from: vimeo.com/23673802

Page 33: 12 Ways to Bounce a Ball

FlipbookTechniques using "Flipbooks"

• Animated Gif • HTML5 Video • CSS Step Animations

Should I ever animate things with Gifs or Video?

Page 34: 12 Ways to Bounce a Ball

FlipbookCSS Step Animations

Page 35: 12 Ways to Bounce a Ball

FlipbookCSS Step Animations

Page 36: 12 Ways to Bounce a Ball

FlipbookCSS Step Animations

Page 37: 12 Ways to Bounce a Ball

Tweening / Keyframes

Beginning State End State

color, width, height, opacity, rotation, x-position, y-position, shadow, font-size, padding, margin, line-height, and more.

Page 38: 12 Ways to Bounce a Ball

Tweening / Keyframes

• SMIL

• Velocity

• Greensock

• CSS Keyframes

• Web Animations API

Most of the 12 ways!

• Mo.js

• Anime

• jQuery

• D3

• Flash

Page 39: 12 Ways to Bounce a Ball

Tweening / Keyframes

Page 40: 12 Ways to Bounce a Ball

Tweening / Keyframes

Page 41: 12 Ways to Bounce a Ball

PerformanceLet your constraints drive your decisions

Page 42: 12 Ways to Bounce a Ball

Performance

Resources

• 10 principles for smooth web animations • jankfree.org • Browser Rendering Optimization Udacity Course

Animation Performance is Rendering Performance

Page 43: 12 Ways to Bounce a Ball

Performance

https://www.html5rocks.com/en/tutorials/speed/high-performance-animations

Page 44: 12 Ways to Bounce a Ball

Other Resources

Questions?

• A Comparison of Animation Technologies

• Codepen Dayton!

@BryanEBraun