• 카테고리

    질문 & 답변
  • 세부 분야

    웹 개발

  • 해결 여부

    미해결

영상 마지막 부분에서 transitionstart가 왜 안먹힐까요?

19.07.15 15:16 작성 조회수 118

0

 

코드를 따라 쓰면서 진행하던 상황이고

end일때는 정상적으로 됐는데

start는 어째서인지 무반응입니다 ㅜ

답변 1

답변을 작성해보세요.

0

아래 코드로 해보시겠어요?

올려주신 코드에서 특별히 이상은 안보입니다~

 

<!DOCTYPE html>

<html>

<head>

  <meta charset="UTF-8">

  <title>Test</title>

  <style>

    .ball {

      width: 50px;

      height: 50px;

      background: dodgerblue;

      transition: 1s;

    }

    .start {

      background: red;

    }

  </style>

</head>

<body>

  <div class="ball"></div>

  <script>

    const ball = document.querySelector('.ball');

    addEventListener('click', function (e) {

      ball.style.transform = 'translate(' + e.clientX + 'px,' + e.clientY + 'px)';

    });

 

    ball.addEventListener('transitionstart', function () {

      this.classList.add('start');

    });

  </script>

</body>

</html>