일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 대표님물리기없기
- 언젠간가겠지
- className
- 접근성
- 포트폴리오
- react-router-dom
- 2020
- windowwidth
- ROUTER 버전6
- set()
- 를
- react-router
- new set()
- 퍼블리싱
- 방심은금물
- classList add
- 커스텀훅
- chart.js
- react
- chart responsive
- 냥빨이다가온다
- 배열중복제거
- 간식금지다!
- classList toggle
- 리엑트할수있는퍼블리셔라규
- 내배위의고양이
- classList
- 안짤렸다
- classList remove
- 클래스 토글
Archives
- Today
- Total
틈
[JS] audio 관련 event 본문
- audio.play()
- audio.pause()
- audio.volume
이 외, 핸들러를 이용한 여러 상태 변경 요소들
- playing-time/duration-time(with progressBar)
const onTimeUpdate = (event) => {
if (event.target.readyState === 0) return;
const currentTime = event.target.currentTime;
const duration = event.target.duration;
const progressBarWidth = (currentTime / duration) * 100;
prograssBar.current.style.width = `${progressBarWidth}%`;
};
- progressBar
const onClickProgress = (event) => {
const progressBarWidth = event.currentTarget.clientWidth;
const offsetX = event.nativeEvent.offsetX;
const duration = audio.current.duration;
audio.current.currentTime = (offsetX / progressBarWidth) * duration;
};
오디오에 관련된 이벤트는 많이 사용하지 않아서
다음번에 사용할 일이 있을 때 다시 찾아야 할 것 같아
한 번 정리해보았다.
React 공부를 하면서 javascript를 많이 배우게 되는데,
핸들러의 종류도 다양하고,
단순히 오브젝트를 옮기고 붙이기 위한 용도가 아닌, 더 깊은 부분의 고려가 보인다.
'code > Javascript' 카테고리의 다른 글
[jQuery] 무한 롤링 (0) | 2022.06.28 |
---|---|
[JS] index 값이 length를 넘어설 때, 0 만들기 (0) | 2022.05.17 |
[JS] 숫자 처리 시 2자리를 맞춰야 할 때 (0) | 2022.05.17 |
[JS] new Date() (0) | 2022.02.15 |
[Javascript] 객체에서 value 에러 처리 (0) | 2022.02.12 |
Comments