
ํด๋ฆญ์
e.clientX,e.clientY๊ฐ์ ๋ฐ๋ผ์ค๋๋ก ํ์. ๊ทธ์น๋ง ๋ง์ฐ์ค๋ณด๋ค ์กฐ๊ธ ๋ bottom + right์ ์์.๋ง์ง์ด ์๊ธฐ ๋๋ฌธ...reset.css๋ก ๋ง์ง ์ ์ง์์
๋, ๋ง์ฐ์ค ์ปค์๋ฅผ ์ผํฐ์ ์์น์ํค๋ ค๋ฉด -15px์ฉ ํด์ค์ผ ๋จ
.ball {
position: absolute;
left: 0;
top: 0;
margin: -15px 0 0 -15px;
}
๋๋
window.addEventListener('click', function (e) {
ballElm.style.transform = `translate(${e.clientX - 15}px, ${e.clientY - 15}px)`;
});

ํธ๋์ง์ ๋๋ฌ์ ๋
transition์ด ์ฌ์๋๋๋ฐ ์ผ๋ง๋ ์๊ฐ์ด ๊ฒฝ๊ณผํ๋
์ฆ, transition-duration ์์ฑ๊ฐ์ด ๋์ด
ballElm.addEventListener('transitionend', function (e) {
ballElm.classList.add('end');
console.log(e.elapsedTime); // 2, 2
console.log(e.propertyName); // transform, bg-color
});

ballElm.addEventListener('transitionstart', function (e) {
ballElm.classList.add('end');
console.log(e.elapsedTime); // 0, 0
console.log(e.propertyName); // transform, bg-color
});

