Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format update for Vibration API #33038

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
update format
  • Loading branch information
skyclouds2001 committed Apr 11, 2024
commit a0eec20b439c00c0efef6ee8343573e5fdc834c8
10 changes: 9 additions & 1 deletion files/en-us/web/api/vibration_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ title: Vibration API
slug: Web/API/Vibration_API
page-type: web-api-overview
browser-compat: api.Navigator.vibrate
spec-urls: https://w3c.github.io/vibration/
---

{{DefaultAPISidebar("Vibration API")}}

Most modern mobile devices include vibration hardware, which lets software code provide physical feedback to the user by causing the device to shake. The **Vibration API** offers Web apps the ability to access this hardware, if it exists, and does nothing if the device doesn't support it.

## Describing vibrations
## Concepts and usage

Vibration is described as a pattern of on-off pulses, which may be of varying lengths. The pattern may consist of either a single integer, describing the number of milliseconds to vibrate, or an array of integers describing a pattern of vibrations and pauses. Vibration is controlled with a single method: {{DOMxRef("Navigator.vibrate()")}}.

Expand Down Expand Up @@ -70,6 +71,13 @@ function startPersistentVibrate(duration, interval) {

Of course, the snippet above doesn't take into account the array method of vibration; persistent array-based vibration will require calculating the sum of the array items and creating an interval based on that number (with an additional delay, probably).

## Interfaces

### Extensions to other interfaces

- {{domxref("Navigator.vibrate()")}}
- : Causes vibration on devices with support for it. Does nothing if vibration support isn't available.

## Specifications

{{Specifications}}
Expand Down