Loading
Brian Birtles
This is a live streamed presentation. You will automatically follow the presenter and see the slide they're currently on.
動く・動かせ・動け!
Brian Birtles
赤塚大典
今できること
CSS Transitions
A → B
CSS Animations
x
(でもCSSTransitionGroupに注意)
4+ (transitions)
5+
1+
10+
3+ (transitions)
4+
Animating like you just don't care with Element.animate()
48+
36+
Priority: Medium
実装中
Page Inspector
Web Cosole
JavaScript Debugger
Network Monitor
Performance Tool
Responsive Design Mode
No libraries
mozilla-central
GitHub
opacity
transform
慶応義塾大学KMD 杉浦研究室
fade in
軽やかにジャンプ
ゆらゆら落ちる
help
これからのアニメ
frames(n) (n ≥ 2)
55+
実装済み?
(昨日)
?
?
// Style:
// transition: opacity 1s
// transitionを発火する
elem.style.opacity = '0';
getComputedStyle(elem);
// 終わったら次の画面をactiveにする
elem.addEventListener('transitionend', evt => {
if (evt.propertyName === 'opacity') {
evt.target.remove();
homeScreen.classList.add('active');
}
});
/*
* でも…
*/
button.addEventListener('focus', () => {
// もしこれがmustacheのようなテンプレート仕組み…
render();
});
transitionendが発火されないケース
transitioncancel | 53+
|
|||
transitionrun | 53+ | |||
transitionstart | 53+ | 10 | ||
animationcancel | 54+ |
Promise.all(
elem.getAnimations().map(animation => animation.finished)
).then(() => {
// アニメーション全部終わった。ハズ。
});
Element.getAnimations()
Nightly
Nightly
Canary
(Experimental web platform features)
'animation-composition'
CSS Animations Level 2
https://drafts.csswg.org/css-animations-2/#animation-composition
const animation = target.animate({ transform: 'scale(2)' },
{ duration: 1000,
fill: 'both' });
animation.timeline =
new ScrollTimeline({ scrollSource: elem });
Scroll-linked animations
Mozilla bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=1321428
// twitter-header-animator.js
registerAnimator('twitter-header', class {
animate(timelines, outputEffects) {
const time = timelines[1].currentTime; // [0...timeRange]
outputEffects[0].localTime = time; // Sets the time used in the first output effect.
outputEffects[1].localTime = Math.min(1, time * 10); // Clamps the input time range.
}
});
// my-page.js
animationWorklet.import('twitter-header-animator.js').then( _ => {
var anim = new WorkletAnimation('twitter-header',
[
new KeyFrameEffect(avatarEl,
{ transform: [ 'translateX(100px)', 'translateX(0px)' ] },
{ duration: 100, iterations: infinite }),
new KeyFrameEffect(headerEl, { opacity: [ 0, 1 ] }, 100)
], [
document.timeline,
new ScrollTimeline(scrollingElement, { timeRange: 100 })
]
);
});
動く・動かせ・動け!
Slide
https://slides.com/birtles/browser-animation-2017
Firefox Developer tools GitHub
https://github.com/devtools-html
Brian
twitter: @brianskold
Daisuke
facebook: dadaaism