
navigator.vibrate를 사용해서
진동의 발생 횟수나 진동 시간을 조정할 수 있습니다.
진동 세기는 기기의 진동 세기 설정 중 알람의 진동 세기와 동일하며
진동 세기는 변경할 수 없습니다.
브라우저 지원 범위
Chrome / Edge / Firefox / Opera / Android 에서 지원한다.
코드 예제
<button
type="button"
onclick="navigator.vibrate(200)">
Basic Vibrate
</button>
<button
type="button"
ontouchstart="navigator.vibrate(100)"
ontouchend="navigator.vibrate(100)">
Mouse Down / Up
</button>
<button
type="button"
ontouchstart="window.timer = setTimeout(() => navigator.vibrate(50), 500)"
ontouchend="clearTimeout(window.timer)">
Long Press
</button>
728x90
'선행개발' 카테고리의 다른 글
메인 스레드 최적화를 위한 Scheduling API (0) | 2023.08.08 |
---|---|
자바스크립트로 공유 기능 커스텀하기 (0) | 2023.07.13 |
자바스크립트로 인터넷 속도 측정하기 (0) | 2023.07.13 |
자바스크립트로 배터리 상태 조회하기 (0) | 2023.07.09 |
선행개발 소개 (0) | 2023.07.06 |