SlideShare a Scribd company logo
1 of 60
www.csiro.au
Performant, accessible
anima4ons with CSS & a dash
of JavaScript
Wing Ho | So$ware Engineer | @soyarsauce
02 August 2018
!
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce2 |
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce3 |
.SlidingBox {
padding: 70px 30px;
background-color: white;
border: 3px solid green;
posi?on: fixed;
opacity: 0;
top: 200px;
transi1on: top 0.6s, opacity 0.6s;
}
.SlidingBox.ac?ve {
opacity: 1;
top: 0;
}
Performant, accessible anima?ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
“Sliding Box”
4 |
2 issues
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce5 |
• Sub-op1mal performance
• Not accessible
Performance
Browser Rendering
Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce7 |
⚡ “60 fps” ⚡
Performant, accessible anima6ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce8 |
“60 fps”
• Common refresh rate of ~60hz on digital displays
• 60 fps = ~16.66ms each frame
• Browser overhead leaves ~10ms each frame
• Exceed 16.66ms => stuBer, low framerate
Performant, accessible animaFons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce9 |
Browser “Render Cycle”
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce10 |
hDps://developers.google.com/web/fundamentals/performance/rendering/
Browser “Render Cycle” - Layout
• Can be triggered by JS or CSS – e.g. width/height, font sizes, top/le<
• When a layout change occurs, browser has to re-flow, re-paint and re-
composite the rest of the page*
*Only specific secFon of the page which requires updaFng
• Expensive (slow to complete)
Performant, accessible animaFons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce11 |
Browser “Render Cycle” - Paint
• background image
• text colour
• shadows
• Expensive (slow to complete)
Performant, accessible anima>ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce12 |
Browser “Render Cycle” - Composite
• opacity
• transform (e.g. translate, scale, rota7on)
• Cheap (quick to complete)
Performant, accessible anima=ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce13 |
.SlidingBox {
padding: 70px 30px;
background-color: white;
border: 3px solid green;
position: fixed;
opacity: 0;
top: 200px;
transition: top 0.6s, opacity 0.6s;
}
.SlidingBox.active {
opacity: 1;
top: 0;
}
Performant, accessible animaEons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
“Sliding Box”
14 |
One small trick that browser
engines don’t want you to know...
Performant, accessible anima;ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce15 |
.PerformantSlidingBox {
padding: 70px 30px;
background-color: white;
border: 3px solid green;
position: fixed;
opacity: 0;
top: 200px;
transform: translateY(200px);
transition: top 0.6s, transform 0.6s, opacity 0.6s;
}
.PerformantSlidingBox.active {
opacity: 1;
top: 0;
transform: translateY(0);
}
Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
“Sliding Box”
16 |
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce17 |
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce18 |
”will-change” property
• Hints to the browser that this element…
will change !
• Typically provide a value of another
property
• Use sparingly
.PerformantSlidingBox {
…
will-change: top;
}
.PerformantSlidingBox {
…
transform: translateZ(0); // old hacky way
}
Performant, accessible animaKons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce19 |
Why
! High end laptop
vs
" Low spec mobile device
Performant, accessible anima9ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce20 |
Why
• Performance gains are universal, regardless of device
• ⬆ Ba5ery life
• " Smoother experience
• # Improved engagement
Performant, accessible anima>ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce21 |
Accessible
.SlidingBox {
padding: 70px 30px;
background-color: white;
border: 3px solid green;
opacity: 0;
posi-on: fixed;
top: 200px;
transi-on: top 0.6s, opacity 0.6s;
}
.SlidingBox.ac@ve {
opacity: 1;
top: 0;
}
Performant, accessible anima@ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
“Sliding, Fading In Box”
23 |
opacity:0 is s,ll in the DOM layout.
Performant, accessible anima,ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce24 |
Accessible
• opacity:0 is s,ll in the DOM layout
• Not consistent experience for assis,ve technology - screen readers
will s,ll read these elements
Performant, accessible anima,ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce25 |
JavaScript-free solutions?
• “display:none”?
• “visibility:hidden”?
Performant, accessible anima:ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce26 |
display:none
• Removes it from the layout / flow completely
• Does not “take up space” in the DOM layout
Performant, accessible anima@ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce27 |
visibility:hidden
• Space is s)ll allocated for the element in the DOM as if it was
visiblity:visible
Performant, accessible anima)ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce28 |
ARIA a&ribute?
• “aria-hidden”
• Requires JavaScript
Performant, accessible anima=ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce29 |
Both break our CSS transition animation.
Performant, accessible anima8ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce30 |
.SlidingBox {
…
visibility:hidden;
}
.SlidingBox.ac0ve {
…
visibility:visible;
}
Performant, accessible anima0ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
visibility:hidden
31 |
.SlidingBox {
…
display:none;
}
.SlidingBox.ac0ve {
…
display:block;
}
Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
display:none
32 |
Fixes?
Performant, accessible anima4ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce33 |
“visibility:hidden” property
• “Animate” visibility by adding a delay to this property
Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce34 |
.SlidingBox {
…
visibility:hidden;
transi'on: transform 0.6s, opacity 0.6s, 0.6s visibility;
}
.SlidingBox.ac9ve {
…
visibility:visible;
}
Performant, accessible anima9ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
visibility:hidden w/ delay
35 |
Fixed! …
Performant, accessible anima6ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce36 |
visibility:hidden - limita0ons
• Only works for visibility, can’t “transi5on” the “display” property.
• Not scalable past simple anima5ons, when you are delaying other
proper5es
Performant, accessible anima5ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce37 |
JavaScript ✨
Performant, accessible anima5ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce38 |
JavaScript
• A dash of JavaScript for maximum accessibility
• Listen for the “transi;onend” or “anima;onend” events
Performant, accessible anima;ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce39 |
Ini$al State > Anima$on State > End State
Performant, accessible anima$ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce40 |
transi'onend
• Triggered when a transition has ended
• Check your expected property has finished animating
• “Clean up” the animation at this point (e.g. toggle CSS classes / aria
attributes, set display/visibility properties, remove from DOM)
Performant, accessible animaGons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce41 |
transi'onend
let element = document.getElementById(“SlidingBox”);
element.addEventListener("transi@onend", () => {
// Toggle class or “display” property directly to remove
}, false);
Performant, accessible anima@ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce42 |
transi'onend
.SlidingBox:not(.active):not(.transitioning) {
visibility:hidden;
}
Performant, accessible anima>ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce43 |
Which is best?
• Pick what is required for your par4cular design & use case
• Consider whether the element needs to stay in the flow, or be removed from
the DOM
• S4ll need JavaScript for toggling aria-roles
Performant, accessible anima4ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce44 |
Which is best?
Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce45 |
Which is best?
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce46 |
Accessible Sliding Boxes?
Performant, accessible anima8ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce47 |
Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce48 |
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
Performant, accessible sliding boxes?
49 |
• Modals
• Menus
• Docks
• ”Toast no1fica1ons”
Accessible Modals
• Modals tend to be fixed/absolute-rela2ve to the document body
• Handle user focus
• document.getElementById(“SlidingBox”).focus()
• aria-roles “dialog, “alertdialog” – include focusable child element
• Make sure user can close the modal
Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce50 |
Accessible Modals
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce51 |
Accessible Modals
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce52 |
x
Seman&cs
❌ <div onClick=“...” />
✅ <bu4on onClick=“...” />
Performant, accessible anima>ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce53 |
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
Give me the React stuff
54 |
• https://github.com/reactjs/react-transition-group
• Great for managing mounting and unmounting with animation at
the forefront
Recap
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
Performant
56 |
• Restrict transi1ons to transforms or opacity when possible
• Use “will-change”, sparingly, when making final op1misa1ons
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
Accessible
57 |
• Ensure elements represented are consistent
• Ensure keyboard users do not get trapped in modals
• Fix opacity anima1ons with (visibility:hidden / display:none) +
aria-hidden=”true”
Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce
Some other resources
58 |
• requestAnima1onFrame
• hGps://csstriggers.com/
• Your browser devtools
• ”FLIP” anima1ons – First Last Invert Play
Live demo? !
Performant, accessible anima5ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce59 |
www.csiro.au
Engineering & Design | Data61
Wing Ho
t twi*er.com/soyarsauce
e wing@wingho.io
w wingho.io | research.csiro.au/data61ux
Thank you

More Related Content

What's hot

CSS Walktrough Internship Course
CSS Walktrough Internship CourseCSS Walktrough Internship Course
CSS Walktrough Internship CourseZoltan Iszlai
 
BILL Hour: Try something new! (like Sass or Compass)
BILL Hour: Try something new! (like Sass or Compass)BILL Hour: Try something new! (like Sass or Compass)
BILL Hour: Try something new! (like Sass or Compass)Reusser Design, LLC
 
Xamarin 9/10 San Diego Meetup
Xamarin 9/10 San Diego MeetupXamarin 9/10 San Diego Meetup
Xamarin 9/10 San Diego MeetupSeamgen
 
Vector Graphics on the Web: SVG, Canvas, CSS3
Vector Graphics on the Web: SVG, Canvas, CSS3Vector Graphics on the Web: SVG, Canvas, CSS3
Vector Graphics on the Web: SVG, Canvas, CSS3Pascal Rettig
 
Getting Started with CoreGraphics
Getting Started with CoreGraphicsGetting Started with CoreGraphics
Getting Started with CoreGraphicsXamarin
 
HTML5 and SVG
HTML5 and SVGHTML5 and SVG
HTML5 and SVGyarcub
 
10 Advanced CSS Techniques (You Wish You Knew More About)
10 Advanced CSS Techniques (You Wish You Knew More About)10 Advanced CSS Techniques (You Wish You Knew More About)
10 Advanced CSS Techniques (You Wish You Knew More About)Emily Lewis
 

What's hot (12)

Html5
Html5Html5
Html5
 
Html5
Html5Html5
Html5
 
Svg
SvgSvg
Svg
 
CSS Walktrough Internship Course
CSS Walktrough Internship CourseCSS Walktrough Internship Course
CSS Walktrough Internship Course
 
BILL Hour: Try something new! (like Sass or Compass)
BILL Hour: Try something new! (like Sass or Compass)BILL Hour: Try something new! (like Sass or Compass)
BILL Hour: Try something new! (like Sass or Compass)
 
Compass/Sass
Compass/SassCompass/Sass
Compass/Sass
 
Xamarin 9/10 San Diego Meetup
Xamarin 9/10 San Diego MeetupXamarin 9/10 San Diego Meetup
Xamarin 9/10 San Diego Meetup
 
Vector Graphics on the Web: SVG, Canvas, CSS3
Vector Graphics on the Web: SVG, Canvas, CSS3Vector Graphics on the Web: SVG, Canvas, CSS3
Vector Graphics on the Web: SVG, Canvas, CSS3
 
Getting Started with CoreGraphics
Getting Started with CoreGraphicsGetting Started with CoreGraphics
Getting Started with CoreGraphics
 
Sass
SassSass
Sass
 
HTML5 and SVG
HTML5 and SVGHTML5 and SVG
HTML5 and SVG
 
10 Advanced CSS Techniques (You Wish You Knew More About)
10 Advanced CSS Techniques (You Wish You Knew More About)10 Advanced CSS Techniques (You Wish You Knew More About)
10 Advanced CSS Techniques (You Wish You Knew More About)
 

Similar to Performant, Accessible Sliding Boxes

Html5 Whats around the bend
Html5 Whats around the bendHtml5 Whats around the bend
Html5 Whats around the bendRaj Lal
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid PrototypingEven Wu
 
The Creative New World of CSS
The Creative New World of CSSThe Creative New World of CSS
The Creative New World of CSSRachel Andrew
 
CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)창석 한
 
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventRobert Nyman
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
 
MTA managing the graphical interface by using css
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using cssDhairya Joshi
 
Comparing XAML and HTML: FIGHT!
Comparing XAML and HTML: FIGHT!Comparing XAML and HTML: FIGHT!
Comparing XAML and HTML: FIGHT!Gill Cleeren
 
Css3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryCss3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryAndrea Verlicchi
 
GOTO Berlin - You can use CSS for that
GOTO Berlin - You can use CSS for thatGOTO Berlin - You can use CSS for that
GOTO Berlin - You can use CSS for thatRachel Andrew
 
[WebVisions 2010] CSS3 Workshop (Afternoon)
[WebVisions 2010] CSS3 Workshop (Afternoon)[WebVisions 2010] CSS3 Workshop (Afternoon)
[WebVisions 2010] CSS3 Workshop (Afternoon)Christopher Schmitt
 
Accessibility Hacks version 2
Accessibility Hacks version 2Accessibility Hacks version 2
Accessibility Hacks version 2Graham Armfield
 
Accessibility Hacks Version 2
Accessibility Hacks Version 2Accessibility Hacks Version 2
Accessibility Hacks Version 2Graham Armfield
 
Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018Graham Armfield
 
Илья Пухальский (EPAM Systems)
Илья Пухальский (EPAM Systems)Илья Пухальский (EPAM Systems)
Илья Пухальский (EPAM Systems)Ontico
 
Keep calm and let's play CSS3
Keep calm and let's play CSS3Keep calm and let's play CSS3
Keep calm and let's play CSS3A2 Comunicação
 

Similar to Performant, Accessible Sliding Boxes (20)

Html5 Whats around the bend
Html5 Whats around the bendHtml5 Whats around the bend
Html5 Whats around the bend
 
CSS and CSS3
CSS and CSS3CSS and CSS3
CSS and CSS3
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
 
The Creative New World of CSS
The Creative New World of CSSThe Creative New World of CSS
The Creative New World of CSS
 
CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)
 
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
 
Iagc2
Iagc2Iagc2
Iagc2
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
MTA managing the graphical interface by using css
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using css
 
Comparing XAML and HTML: FIGHT!
Comparing XAML and HTML: FIGHT!Comparing XAML and HTML: FIGHT!
Comparing XAML and HTML: FIGHT!
 
Css3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryCss3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQuery
 
CSS for Mobile
CSS for MobileCSS for Mobile
CSS for Mobile
 
GOTO Berlin - You can use CSS for that
GOTO Berlin - You can use CSS for thatGOTO Berlin - You can use CSS for that
GOTO Berlin - You can use CSS for that
 
[WebVisions 2010] CSS3 Workshop (Afternoon)
[WebVisions 2010] CSS3 Workshop (Afternoon)[WebVisions 2010] CSS3 Workshop (Afternoon)
[WebVisions 2010] CSS3 Workshop (Afternoon)
 
Accessibility Hacks version 2
Accessibility Hacks version 2Accessibility Hacks version 2
Accessibility Hacks version 2
 
Accessibility Hacks Version 2
Accessibility Hacks Version 2Accessibility Hacks Version 2
Accessibility Hacks Version 2
 
CSS3 3D Workshop
CSS3 3D WorkshopCSS3 3D Workshop
CSS3 3D Workshop
 
Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018
 
Илья Пухальский (EPAM Systems)
Илья Пухальский (EPAM Systems)Илья Пухальский (EPAM Systems)
Илья Пухальский (EPAM Systems)
 
Keep calm and let's play CSS3
Keep calm and let's play CSS3Keep calm and let's play CSS3
Keep calm and let's play CSS3
 

Recently uploaded

cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 

Recently uploaded (20)

cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Performant, Accessible Sliding Boxes

  • 1. www.csiro.au Performant, accessible anima4ons with CSS & a dash of JavaScript Wing Ho | So$ware Engineer | @soyarsauce 02 August 2018
  • 2. ! Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce2 |
  • 3. Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce3 |
  • 4. .SlidingBox { padding: 70px 30px; background-color: white; border: 3px solid green; posi?on: fixed; opacity: 0; top: 200px; transi1on: top 0.6s, opacity 0.6s; } .SlidingBox.ac?ve { opacity: 1; top: 0; } Performant, accessible anima?ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce “Sliding Box” 4 |
  • 5. 2 issues Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce5 | • Sub-op1mal performance • Not accessible
  • 7. Browser Rendering Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce7 |
  • 8. ⚡ “60 fps” ⚡ Performant, accessible anima6ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce8 |
  • 9. “60 fps” • Common refresh rate of ~60hz on digital displays • 60 fps = ~16.66ms each frame • Browser overhead leaves ~10ms each frame • Exceed 16.66ms => stuBer, low framerate Performant, accessible animaFons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce9 |
  • 10. Browser “Render Cycle” Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce10 | hDps://developers.google.com/web/fundamentals/performance/rendering/
  • 11. Browser “Render Cycle” - Layout • Can be triggered by JS or CSS – e.g. width/height, font sizes, top/le< • When a layout change occurs, browser has to re-flow, re-paint and re- composite the rest of the page* *Only specific secFon of the page which requires updaFng • Expensive (slow to complete) Performant, accessible animaFons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce11 |
  • 12. Browser “Render Cycle” - Paint • background image • text colour • shadows • Expensive (slow to complete) Performant, accessible anima>ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce12 |
  • 13. Browser “Render Cycle” - Composite • opacity • transform (e.g. translate, scale, rota7on) • Cheap (quick to complete) Performant, accessible anima=ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce13 |
  • 14. .SlidingBox { padding: 70px 30px; background-color: white; border: 3px solid green; position: fixed; opacity: 0; top: 200px; transition: top 0.6s, opacity 0.6s; } .SlidingBox.active { opacity: 1; top: 0; } Performant, accessible animaEons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce “Sliding Box” 14 |
  • 15. One small trick that browser engines don’t want you to know... Performant, accessible anima;ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce15 |
  • 16. .PerformantSlidingBox { padding: 70px 30px; background-color: white; border: 3px solid green; position: fixed; opacity: 0; top: 200px; transform: translateY(200px); transition: top 0.6s, transform 0.6s, opacity 0.6s; } .PerformantSlidingBox.active { opacity: 1; top: 0; transform: translateY(0); } Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce “Sliding Box” 16 |
  • 17. Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce17 |
  • 18. Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce18 |
  • 19. ”will-change” property • Hints to the browser that this element… will change ! • Typically provide a value of another property • Use sparingly .PerformantSlidingBox { … will-change: top; } .PerformantSlidingBox { … transform: translateZ(0); // old hacky way } Performant, accessible animaKons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce19 |
  • 20. Why ! High end laptop vs " Low spec mobile device Performant, accessible anima9ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce20 |
  • 21. Why • Performance gains are universal, regardless of device • ⬆ Ba5ery life • " Smoother experience • # Improved engagement Performant, accessible anima>ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce21 |
  • 23. .SlidingBox { padding: 70px 30px; background-color: white; border: 3px solid green; opacity: 0; posi-on: fixed; top: 200px; transi-on: top 0.6s, opacity 0.6s; } .SlidingBox.ac@ve { opacity: 1; top: 0; } Performant, accessible anima@ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce “Sliding, Fading In Box” 23 |
  • 24. opacity:0 is s,ll in the DOM layout. Performant, accessible anima,ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce24 |
  • 25. Accessible • opacity:0 is s,ll in the DOM layout • Not consistent experience for assis,ve technology - screen readers will s,ll read these elements Performant, accessible anima,ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce25 |
  • 26. JavaScript-free solutions? • “display:none”? • “visibility:hidden”? Performant, accessible anima:ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce26 |
  • 27. display:none • Removes it from the layout / flow completely • Does not “take up space” in the DOM layout Performant, accessible anima@ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce27 |
  • 28. visibility:hidden • Space is s)ll allocated for the element in the DOM as if it was visiblity:visible Performant, accessible anima)ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce28 |
  • 29. ARIA a&ribute? • “aria-hidden” • Requires JavaScript Performant, accessible anima=ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce29 |
  • 30. Both break our CSS transition animation. Performant, accessible anima8ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce30 |
  • 31. .SlidingBox { … visibility:hidden; } .SlidingBox.ac0ve { … visibility:visible; } Performant, accessible anima0ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce visibility:hidden 31 |
  • 32. .SlidingBox { … display:none; } .SlidingBox.ac0ve { … display:block; } Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce display:none 32 |
  • 33. Fixes? Performant, accessible anima4ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce33 |
  • 34. “visibility:hidden” property • “Animate” visibility by adding a delay to this property Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce34 |
  • 35. .SlidingBox { … visibility:hidden; transi'on: transform 0.6s, opacity 0.6s, 0.6s visibility; } .SlidingBox.ac9ve { … visibility:visible; } Performant, accessible anima9ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce visibility:hidden w/ delay 35 |
  • 36. Fixed! … Performant, accessible anima6ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce36 |
  • 37. visibility:hidden - limita0ons • Only works for visibility, can’t “transi5on” the “display” property. • Not scalable past simple anima5ons, when you are delaying other proper5es Performant, accessible anima5ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce37 |
  • 38. JavaScript ✨ Performant, accessible anima5ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce38 |
  • 39. JavaScript • A dash of JavaScript for maximum accessibility • Listen for the “transi;onend” or “anima;onend” events Performant, accessible anima;ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce39 |
  • 40. Ini$al State > Anima$on State > End State Performant, accessible anima$ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce40 |
  • 41. transi'onend • Triggered when a transition has ended • Check your expected property has finished animating • “Clean up” the animation at this point (e.g. toggle CSS classes / aria attributes, set display/visibility properties, remove from DOM) Performant, accessible animaGons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce41 |
  • 42. transi'onend let element = document.getElementById(“SlidingBox”); element.addEventListener("transi@onend", () => { // Toggle class or “display” property directly to remove }, false); Performant, accessible anima@ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce42 |
  • 43. transi'onend .SlidingBox:not(.active):not(.transitioning) { visibility:hidden; } Performant, accessible anima>ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce43 |
  • 44. Which is best? • Pick what is required for your par4cular design & use case • Consider whether the element needs to stay in the flow, or be removed from the DOM • S4ll need JavaScript for toggling aria-roles Performant, accessible anima4ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce44 |
  • 45. Which is best? Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce45 |
  • 46. Which is best? Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce46 |
  • 47. Accessible Sliding Boxes? Performant, accessible anima8ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce47 |
  • 48. Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce48 |
  • 49. Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce Performant, accessible sliding boxes? 49 | • Modals • Menus • Docks • ”Toast no1fica1ons”
  • 50. Accessible Modals • Modals tend to be fixed/absolute-rela2ve to the document body • Handle user focus • document.getElementById(“SlidingBox”).focus() • aria-roles “dialog, “alertdialog” – include focusable child element • Make sure user can close the modal Performant, accessible animations with CSS & a dash of JavaScript | Wing Ho | @soyarsauce50 |
  • 51. Accessible Modals Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce51 |
  • 52. Accessible Modals Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce52 | x
  • 53. Seman&cs ❌ <div onClick=“...” /> ✅ <bu4on onClick=“...” /> Performant, accessible anima>ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce53 |
  • 54. Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce Give me the React stuff 54 | • https://github.com/reactjs/react-transition-group • Great for managing mounting and unmounting with animation at the forefront
  • 55. Recap
  • 56. Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce Performant 56 | • Restrict transi1ons to transforms or opacity when possible • Use “will-change”, sparingly, when making final op1misa1ons
  • 57. Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce Accessible 57 | • Ensure elements represented are consistent • Ensure keyboard users do not get trapped in modals • Fix opacity anima1ons with (visibility:hidden / display:none) + aria-hidden=”true”
  • 58. Performant, accessible anima1ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce Some other resources 58 | • requestAnima1onFrame • hGps://csstriggers.com/ • Your browser devtools • ”FLIP” anima1ons – First Last Invert Play
  • 59. Live demo? ! Performant, accessible anima5ons with CSS & a dash of JavaScript | Wing Ho | @soyarsauce59 |
  • 60. www.csiro.au Engineering & Design | Data61 Wing Ho t twi*er.com/soyarsauce e wing@wingho.io w wingho.io | research.csiro.au/data61ux Thank you