Slide 53
Slide 53 text
class BetterButton extends HTMLElement {
}
drawRipple(x, y) {
let div = document.createElement('div');
div.classList.add('ripple');
this.appendChild(div);
div.style.top = `${y - div.clientHeight/2}px`;
div.style.left = `${x - div.clientWidth/2}px`;
// Make ripple color same as text color.
div.style.backgroundColor = getComputedStyle(this).color;
div.classList.add(‘run');
div.addEventListener(
'transitionend', e => div.remove());
}
better-button .ripple {
position: absolute;
transform: scale3d(0,0,0);
opacity: 0.8;
transition: all 800ms cubic-bezier(0.4,0,0.2,1);
border-radius: 50%;
width: 150px; height: 150px;
will-change: opacity, transform;
contain: content;
}
better-button .ripple.run {
opacity: 0; transform: none;
}