• 회원가입
  • 로그인
  • 구글아이디로 로그인

[DOM_Event] JS - animationstart 이벤트 (= onanimationstart 속성) - CSS 애니메인션 시작 (IE10 이상)

animationstart 예제

 

<style> 

#hz {

  margin: 25px;

  width: 400px;

  line-height: 100px;

  text-align:center;

  background: yellow;

  position: relative;

  font-size: 20px;

}


/* Chrome, Safari, Opera */

@-webkit-keyframes hzmove {

  from {top: 0px;}

  to {top: 200px;}

}


@keyframes hzmove {

  from {top: 0px;}

  to {top: 200px;}

}

</style>



<div id="hz" onclick="homzzang()">홈짱닷컴 Homzzang.com [클릭]</div>


<script>

var x = document.getElementById("hz");


// Start the animation with JavaScript

function homzzang() {

  x.style.WebkitAnimation = "hzmove 4s 2"; // Code for Chrome, Safari and Opera

  x.style.animation = "hzmove 4s 2";     // Standard syntax

}


// Chrome, Safari and Opera

x.addEventListener("webkitAnimationStart", homzzangStart);

x.addEventListener("webkitAnimationIteration", homzzangRepeat);

x.addEventListener("webkitAnimationEnd", homzzangEnd);


// 표준

x.addEventListener("animationstart", homzzangStart);

x.addEventListener("animationiteration", homzzangRepeat);

x.addEventListener("animationend", homzzangEnd);


function homzzangStart() {

  this.innerHTML = "animationstart 이벤트 - 이동 시작";

  this.style.backgroundColor = "tomato";

}


function homzzangRepeat() {

  this.innerHTML = "animationiteration 이벤트 - 이동 반복";

  this.style.backgroundColor = "pink";

}


function homzzangEnd() {

  this.innerHTML = "animationend 이벤트 - 이동 종료";

  this.style.backgroundColor = "lightgray";

}

</script> 

 

결과보기


 

animationstart 정의

 

 CSS 애니메이션 시작할 때 발생.

 


 

1.

CSS3 animation 참조.

 

2.

관련 이벤트 3가지.

 

animationstart

CSS 애니메이션 시작 때 발생.

 

animationiteration

CSS 애니메이션 반복 때 발생.

 

animationend

CSS 애니메이션 완료 때 발생.


3.

IE10 이상 주요 최신 브라우저 지원.
Chrome, Safari, Opera 접두어: webkit

Firefox 접두어 : moz

 

4.

이벤트확산 : O
취소가능성 : X

이벤트타입 : AnimationEvent

지원 HTML : 

DOM 버전 : Level 3 Events

 

 

 

animationstart 구문

 

object.addEventListener("webkitAnimationStart", homzzang);  // Chrome, Safari, Opera

object.addEventListener("animationstart", homzzang); // Standard

 

※ homzzang : 실행함수명.

※ addEventLister() 방식 주의사항 2가지 : (이벤트명에 on 안 붙인. / 실행함수명 뒤에 소괄호 안 붙임)

※ addEventListener() 메서드는 IE8 및 그 이전 브라우저는 지원 안 함. 



분류 제목
DOM_Event_Object JS - StorageEvent 객체 - 윈도우창 저장영역 변경 (= 스토리지이벤트객체= 스토리지이벤트종류)
DOM_Event_Object JS - TouchEvent 객체 - 터치이벤트객체 (= 터치이벤트종류)
DOM_Event_Object JS - TransitionEvent 객체 - CSS 전환 실행 (= 트랜지션이벤트객체 = 트랜지션이벤트종류…
DOM_Event_Object JS - UiEvent 객체 - 유저인터페이스변환 (= 유아이이벤트객체 = 유저인터페이스이벤트종류 = 사용자…
DOM_Event_Object JS - WheelEvent 객체 - 마우스휠움직임 (= 휠이벤트객체)
API_Geolocation JS - coordinates -
API_Geolocation JS - position -
API_Geolocation JS - positionError -
API_Geolocation JS - positionOptions -
API_Geolocation JS - clearWatch() 메서드 -
API_Geolocation JS - getCurrentPosition() 메서드 -
API_Geolocation JS - watchPosition() 메서드 -
Window_History JS - history.length 속성 - history개수 (= 방문이력개수 = 방문주소개수 = 히스토리…
Window_History JS - history.back() 메서드 ★ - 이전페이지 가기
Window_History JS - history.forward() 메서드 - 다음페이지 가기
Window_History JS - history.go() 메서드 ★ - 특정페이지로 이동 (= history.go메서드 = 히스토리고…
DOM_HTMLCollection JS - item() 메서드 ★ - 지정 인덱스의 요소 반환 (= 특정 순번째 요소 반환)
DOM_HTMLCollection JS - length 속성 ★ - 요소개수 반환 (※ for반복문에 활용)
DOM_HTMLCollection JS - namedItem() 메서드 - 지정 id 또는 name 갖는 요소 반환
Window_Location JS - hash 속성 - URL앵커부분(= 샵부분 = 해시속성) 설정/반환
40/67
목록
찾아주셔서 감사합니다. Since 2012