SlideShare uma empresa Scribd logo
1 de 16
CSS Animations &
Transitions
Refresh Hilo 2/10/15
What’s going to be covered
● What are Transitions & Animations
● Pros and Cons
● Performance
Transitions
div {
color:black;
transition: color 1s linear 500ms;
transition-property: color;
transition-duration: 1s;
transition-timing-function: linear;
transition-delay: 500ms; }
div:hover {color:red;}
Transitions
● Transition property - what will change
● Transition duration - animation time
● Transition timing function - animation speed curve
● Transition delay - time before animation
Must have a property and duration set for transition
animations to work!
Transitions
Changes transition property from one state to another.
● Set animation in current state, modify state with pseudo
classes (:hover,:focus) or classes (.active)
● Multiple properties can be animated
● Animation properties can be changed (Javascript &
:pseudo)
● JS listeners on transition end: ‘transitionend’
● Properties List
● Demo
Questions?
Animations
div { animation: GoAnimate 2s;}
@keyframes GoAnimate {
from { color: black;}
to { color: red;}
}
Animations
div {
animation-name: GoAnimate;
animation-duration: 1s;
animation-timing-function: linear;
animation-delay: 500ms;
animation-iteration-count: infinite;
animation-direction: normal;
animation-play-state: running;
animation-fill-mode: forward;
}
@keyframes GoAnimate {
0% { color: black;}
25% {color:pink;}
50% {color:orange;}
75% {color:blue;}
100% { color: red;}
}
Animations
● Animation name - name of defined animation
● Animation duration, timing function, delay same as
transition
● Animation iteration count - how many times it will loop
● Animation direction - direction and alternate cycles
● Animation play state - running or paused (can toggle)
● Animation fill mode - sets end state after animation
Must have a name and duration set for animations to
work!
Animations
● Once an animation is applied it can’t be changed, only
paused (animation-play-state) - can be changed with
JS, but resets the animation
● JS listeners on start, iteration, end of animation (not
paused) - event object is useful, ‘elapsedTime’
o ‘animationstart’, ‘animationiteration’, ‘animationend’
● Don’t forget animation-fill-mode
● Properties List
● Demo Swing, Demo Play State
Questions?
Pros & Cons
Transitions Pros
● Good for :pseudo-classes
(:hover,:active)
● Does not require JS
● Reversible - easy state change
● Easy to use
Transitions Cons
● Simple only
● Browser prefixes (-webkit)
● Sometimes requires JS
assistance - change the height of
something
Animations Pros
● Complex Animations with
multiple keyframes (0%, 1%,
5%)
● JS listeners
● Defined Animations - modular
Animations Cons
● Can’t change without JS - no
easy reverse
● Browser prefixes
● Complex interactions require JS
Performance
How do you measure performance?
Chrome dev tools > timeline
Record Animation and review results.
Goal > 30fps - target is around 60fps
Performance
CPU vs GPU Animation: Most animation use the CPU,
animations that use transforms (sometimes) use the GPU.
● Use transform:translate() vs TRBL
o TRBL uses whole pixels - requires more paint time
o transform:translate uses subpixels and tweens
animation smoother - no stair stepping
● Low cost animations = position(transform), rotation,
scale, opacity
Performance
TRBL transform:translate
Scripting = JS events, functions, etc
Rendering = layout
Painting = pixels on screen
Idle = sipping Mai-Tai’s
Questions?
Edward Meehan - Refresh Hilo 2015

Mais conteúdo relacionado

Mais procurados

Images and Tables in HTML
Images and Tables in HTMLImages and Tables in HTML
Images and Tables in HTML
Aarti P
 
Java servlets
Java servletsJava servlets
Java servlets
lopjuan
 

Mais procurados (20)

Css
CssCss
Css
 
CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout
 
Css position
Css positionCss position
Css position
 
HTML5 Canvas
HTML5 CanvasHTML5 Canvas
HTML5 Canvas
 
CSS Dasar #1 : Intro
CSS Dasar #1 : IntroCSS Dasar #1 : Intro
CSS Dasar #1 : Intro
 
Dhtml ppt (2)
Dhtml ppt (2)Dhtml ppt (2)
Dhtml ppt (2)
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
 
Html frames
Html framesHtml frames
Html frames
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overview
 
Html 5 tutorial - By Bally Chohan
Html 5 tutorial - By Bally ChohanHtml 5 tutorial - By Bally Chohan
Html 5 tutorial - By Bally Chohan
 
Html5 semantics
Html5 semanticsHtml5 semantics
Html5 semantics
 
Images and Tables in HTML
Images and Tables in HTMLImages and Tables in HTML
Images and Tables in HTML
 
New Elements & Features in HTML5
New Elements & Features in HTML5New Elements & Features in HTML5
New Elements & Features in HTML5
 
Css selectors
Css selectorsCss selectors
Css selectors
 
Java servlets
Java servletsJava servlets
Java servlets
 
html5.ppt
html5.ppthtml5.ppt
html5.ppt
 
HTML5 introduction for beginners
HTML5 introduction for beginnersHTML5 introduction for beginners
HTML5 introduction for beginners
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
CSS
CSSCSS
CSS
 
HTML Semantic Elements
HTML Semantic ElementsHTML Semantic Elements
HTML Semantic Elements
 

Destaque

JS.Chi CSS Animations
JS.Chi CSS AnimationsJS.Chi CSS Animations
JS.Chi CSS Animations
Justin Meyer
 

Destaque (20)

Css animation
Css animationCss animation
Css animation
 
Css3animation
Css3animationCss3animation
Css3animation
 
Honey con 2014
Honey con 2014Honey con 2014
Honey con 2014
 
Introduction to HTML5 & CSS3
Introduction to HTML5 & CSS3Introduction to HTML5 & CSS3
Introduction to HTML5 & CSS3
 
JS.Chi CSS Animations
JS.Chi CSS AnimationsJS.Chi CSS Animations
JS.Chi CSS Animations
 
Ad 8
Ad 8Ad 8
Ad 8
 
CSS3 filterとtransformをtransition, animationでアニメーション
CSS3 filterとtransformをtransition, animationでアニメーションCSS3 filterとtransformをtransition, animationでアニメーション
CSS3 filterとtransformをtransition, animationでアニメーション
 
Session and cookies ,get and post methods
Session and cookies ,get and post methodsSession and cookies ,get and post methods
Session and cookies ,get and post methods
 
Dynamic CSS: Transforms, Transitions, and Animation Basics
Dynamic CSS: Transforms, Transitions, and Animation BasicsDynamic CSS: Transforms, Transitions, and Animation Basics
Dynamic CSS: Transforms, Transitions, and Animation Basics
 
CSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and AnimationsCSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and Animations
 
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
 
Fundamental HTML5
Fundamental HTML5Fundamental HTML5
Fundamental HTML5
 
2. HTML forms
2. HTML forms2. HTML forms
2. HTML forms
 
Introducing CSS Grid Layout
Introducing CSS Grid LayoutIntroducing CSS Grid Layout
Introducing CSS Grid Layout
 
Html forms
Html formsHtml forms
Html forms
 
Fundamental CSS3
Fundamental CSS3Fundamental CSS3
Fundamental CSS3
 
Intro to CSS3
Intro to CSS3Intro to CSS3
Intro to CSS3
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
HTML CSS Basics
HTML CSS BasicsHTML CSS Basics
HTML CSS Basics
 
reveal.js 3.0.0
reveal.js 3.0.0reveal.js 3.0.0
reveal.js 3.0.0
 

Semelhante a CSS Animations & Transitions

CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)
창석 한
 
ios_summit_2016_korhan
ios_summit_2016_korhanios_summit_2016_korhan
ios_summit_2016_korhan
Korhan Bircan
 
Building animated UI with Core Animation
Building animated UI with Core AnimationBuilding animated UI with Core Animation
Building animated UI with Core Animation
Marco Zoffoli
 

Semelhante a CSS Animations & Transitions (20)

Lesson 17
Lesson 17Lesson 17
Lesson 17
 
Lesson 17
Lesson 17Lesson 17
Lesson 17
 
Android App Development - 12 animations
Android App Development - 12 animationsAndroid App Development - 12 animations
Android App Development - 12 animations
 
Make your animations perform well
Make your animations perform wellMake your animations perform well
Make your animations perform well
 
Demystifying Angular Animations
Demystifying Angular AnimationsDemystifying Angular Animations
Demystifying Angular Animations
 
Make your animations perform well - Anna Migas - Codemotion Rome 2017
Make your animations perform well - Anna Migas - Codemotion Rome 2017Make your animations perform well - Anna Migas - Codemotion Rome 2017
Make your animations perform well - Anna Migas - Codemotion Rome 2017
 
Make Your Animations Perform Well - JS Conf Budapest 2017
Make Your Animations Perform Well - JS Conf Budapest 2017 Make Your Animations Perform Well - JS Conf Budapest 2017
Make Your Animations Perform Well - JS Conf Budapest 2017
 
HalfStack London - Make Your Animations Perform Well
HalfStack London - Make Your Animations Perform Well HalfStack London - Make Your Animations Perform Well
HalfStack London - Make Your Animations Perform Well
 
CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)
 
Animation With Flutter.pptx
Animation With Flutter.pptxAnimation With Flutter.pptx
Animation With Flutter.pptx
 
Choosing your animation adventure - Generate NYC 2018
Choosing your animation adventure  - Generate NYC 2018Choosing your animation adventure  - Generate NYC 2018
Choosing your animation adventure - Generate NYC 2018
 
Basic Android Animation
Basic Android Animation Basic Android Animation
Basic Android Animation
 
ios_summit_2016_korhan
ios_summit_2016_korhanios_summit_2016_korhan
ios_summit_2016_korhan
 
Day seven
Day sevenDay seven
Day seven
 
Neoito — Animations in Angular 5
Neoito — Animations in Angular 5Neoito — Animations in Angular 5
Neoito — Animations in Angular 5
 
animations
animationsanimations
animations
 
CSS3 Animations & Transitions with PhoneGap
CSS3 Animations & Transitions with PhoneGapCSS3 Animations & Transitions with PhoneGap
CSS3 Animations & Transitions with PhoneGap
 
Workshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effectsWorkshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effects
 
Building animated UI with Core Animation
Building animated UI with Core AnimationBuilding animated UI with Core Animation
Building animated UI with Core Animation
 
Smooth Animations for Web & Hybrid
Smooth Animations for Web & HybridSmooth Animations for Web & Hybrid
Smooth Animations for Web & Hybrid
 

Mais de Edward Meehan (10)

Remote working
Remote workingRemote working
Remote working
 
Comps into pages 102
Comps into pages 102Comps into pages 102
Comps into pages 102
 
Sketch - Refresh Hilo
Sketch - Refresh HiloSketch - Refresh Hilo
Sketch - Refresh Hilo
 
Comps into pages 101
Comps into pages 101Comps into pages 101
Comps into pages 101
 
Capistrano demo
Capistrano demoCapistrano demo
Capistrano demo
 
Refresh hilo 09/09/2014
Refresh hilo 09/09/2014Refresh hilo 09/09/2014
Refresh hilo 09/09/2014
 
Drupal - Content Types, Views = No Query Headaches
Drupal - Content Types, Views = No Query HeadachesDrupal - Content Types, Views = No Query Headaches
Drupal - Content Types, Views = No Query Headaches
 
Refresh hilo-08122014
Refresh hilo-08122014Refresh hilo-08122014
Refresh hilo-08122014
 
Rapid prototype demo
Rapid prototype demoRapid prototype demo
Rapid prototype demo
 
Jekyll demo - Refresh Hilo
Jekyll demo - Refresh HiloJekyll demo - Refresh Hilo
Jekyll demo - Refresh Hilo
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

CSS Animations & Transitions

  • 2. What’s going to be covered ● What are Transitions & Animations ● Pros and Cons ● Performance
  • 3. Transitions div { color:black; transition: color 1s linear 500ms; transition-property: color; transition-duration: 1s; transition-timing-function: linear; transition-delay: 500ms; } div:hover {color:red;}
  • 4. Transitions ● Transition property - what will change ● Transition duration - animation time ● Transition timing function - animation speed curve ● Transition delay - time before animation Must have a property and duration set for transition animations to work!
  • 5. Transitions Changes transition property from one state to another. ● Set animation in current state, modify state with pseudo classes (:hover,:focus) or classes (.active) ● Multiple properties can be animated ● Animation properties can be changed (Javascript & :pseudo) ● JS listeners on transition end: ‘transitionend’ ● Properties List ● Demo
  • 7. Animations div { animation: GoAnimate 2s;} @keyframes GoAnimate { from { color: black;} to { color: red;} }
  • 8. Animations div { animation-name: GoAnimate; animation-duration: 1s; animation-timing-function: linear; animation-delay: 500ms; animation-iteration-count: infinite; animation-direction: normal; animation-play-state: running; animation-fill-mode: forward; } @keyframes GoAnimate { 0% { color: black;} 25% {color:pink;} 50% {color:orange;} 75% {color:blue;} 100% { color: red;} }
  • 9. Animations ● Animation name - name of defined animation ● Animation duration, timing function, delay same as transition ● Animation iteration count - how many times it will loop ● Animation direction - direction and alternate cycles ● Animation play state - running or paused (can toggle) ● Animation fill mode - sets end state after animation Must have a name and duration set for animations to work!
  • 10. Animations ● Once an animation is applied it can’t be changed, only paused (animation-play-state) - can be changed with JS, but resets the animation ● JS listeners on start, iteration, end of animation (not paused) - event object is useful, ‘elapsedTime’ o ‘animationstart’, ‘animationiteration’, ‘animationend’ ● Don’t forget animation-fill-mode ● Properties List ● Demo Swing, Demo Play State
  • 12. Pros & Cons Transitions Pros ● Good for :pseudo-classes (:hover,:active) ● Does not require JS ● Reversible - easy state change ● Easy to use Transitions Cons ● Simple only ● Browser prefixes (-webkit) ● Sometimes requires JS assistance - change the height of something Animations Pros ● Complex Animations with multiple keyframes (0%, 1%, 5%) ● JS listeners ● Defined Animations - modular Animations Cons ● Can’t change without JS - no easy reverse ● Browser prefixes ● Complex interactions require JS
  • 13. Performance How do you measure performance? Chrome dev tools > timeline Record Animation and review results. Goal > 30fps - target is around 60fps
  • 14. Performance CPU vs GPU Animation: Most animation use the CPU, animations that use transforms (sometimes) use the GPU. ● Use transform:translate() vs TRBL o TRBL uses whole pixels - requires more paint time o transform:translate uses subpixels and tweens animation smoother - no stair stepping ● Low cost animations = position(transform), rotation, scale, opacity
  • 15. Performance TRBL transform:translate Scripting = JS events, functions, etc Rendering = layout Painting = pixels on screen Idle = sipping Mai-Tai’s
  • 16. Questions? Edward Meehan - Refresh Hilo 2015