$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Super Smooth Animations
Search
Giacomo "Giko" Zinetti
March 16, 2018
Programming
1
100
Super Smooth Animations
Speech for CSSDay in Faenza (Italy)
March, 16th 2018
Live on
https://cssday2018.slides.giko.it/
Giacomo "Giko" Zinetti
March 16, 2018
Tweet
Share
More Decks by Giacomo "Giko" Zinetti
See All by Giacomo "Giko" Zinetti
Cmd Alt I - Chrome Dev tools
gcmznt
0
75
ES2015 new features
gcmznt
0
53
CSS from the future
gcmznt
0
38
Web performance & Http2
gcmznt
0
58
CSS variables
gcmznt
2
110
CSS Performance
gcmznt
2
82
Other Decks in Programming
See All in Programming
マスタデータ問題、マイクロサービスでどう解くか
kts
0
100
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
510
ゲームの物理 剛体編
fadis
0
350
認証・認可の基本を学ぼう後編
kouyuume
0
240
React Native New Architecture 移行実践報告
taminif
1
160
非同期処理の迷宮を抜ける: 初学者がつまづく構造的な原因
pd1xx
1
720
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
120
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
130
Canon EOS R50 V と R5 Mark II 購入でみえてきた最近のデジイチ VR180 事情、そして VR180 静止画に活路を見出すまで
karad
0
120
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
440
UIデザインに役立つ 2025年の最新CSS / The Latest CSS for UI Design 2025
clockmaker
18
7.5k
Flutter On-device AI로 완성하는 오프라인 앱, 박제창 @DevFest INCHEON 2025
itsmedreamwalker
1
110
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1371
200k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Statistics for Hackers
jakevdp
799
230k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
The Language of Interfaces
destraynor
162
25k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
70k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.5k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Docker and Python
trallard
47
3.7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Transcript
Super smooth animations
Expectation Expectation
Reality Reality
Battery drain Battery drain
Device Device overheating overheating
Maillard Maillard
Giacomo Zinetti Giacomo Zinetti @gcmznt @gcmznt
How browser How browser renders? renders?
Render Render cycle cycle JavaScript JavaScript Style Style Layout Layout
Paint Paint Composite Composite
Our logic Our logic JavaScript JavaScript Style Style Layout Layout
Paint Paint Composite Composite
margin margin padding padding Reflow Reflow JavaScript JavaScript Style Style
Layout Layout Paint Paint Composite Composite
color color background background Repaint Repaint JavaScript JavaScript Style Style
Layout Layout Paint Paint Composite Composite
transform transform opacity opacity Compose Compose JavaScript JavaScript Style Style
Layout Layout Paint Paint Composite Composite
CSS CSS
Animate Animate compositor-only compositor-only properties properties
Execute long JS task Start heavy JS loop Left Translate
Create layers Create layers will-change will-change
❌ ❌ * { * { will-change: transform; will-change: transform;
} }
Disable hover Disable hover on scroll on scroll
JS JS
Avoid forced Avoid forced synchronous synchronous layout layout
❌ ❌ elements.forEach(el => { elements.forEach(el => { el.querySelector('img').style.width el.querySelector('img').style.width
= `${el.offsetWidth}px`; = `${el.offsetWidth}px`; }) })
elements.forEach((el, i) => { elements.forEach((el, i) => { ws[i] =
el.offsetWidth; ws[i] = el.offsetWidth; }) }) elements.forEach((el, i) => { elements.forEach((el, i) => { el.querySelector('img').style.width el.querySelector('img').style.width = `${ws[i]}px`; = `${ws[i]}px`; }) })
rAF rAF requestAnimationFrame() requestAnimationFrame()
rIC rIC requestIdleCallback() requestIdleCallback()
Split big tasks Split big tasks
Web workers Web workers
TARGET TARGET RAIL RAIL
Response <100ms Response <100ms Animation <16ms Animation <16ms Idle <50ms
Idle <50ms Load <1000ms Load <1000ms
FLIP FLIP by @aerotwist by @aerotwist
First First const first = const first = el.getBoundingClientRect(); el.getBoundingClientRect();
Last Last el.classList.toggle('end'); el.classList.toggle('end'); const last = const last =
el.getBoundingClientRect(); el.getBoundingClientRect();
Invert Invert const invert = const invert = first.height /
last.height; first.height / last.height;
Play Play el.animate([ el.animate([ { transform: `scale(${invert}px)` }, { transform:
`scale(${invert}px)` }, { transform: 'scale(0)' } { transform: 'scale(0)' } ], 300); ], 300);
First First Last Last Invert Invert Play Play
None
Content Content VS VS Animations Animations
Users! Users!
The best animation The best animation is the invisible one
is the invisible one Thank you Thank you
Links Links This slides Codepen examples Feedbacks are welcome! Web
Fundamentals: Performance CSS Triggers FLIP by @aerotwist