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
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion files/en-us/web/api/navigator/vibrate/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ browser-compat: api.Navigator.vibrate

{{APIRef("Vibration API")}}

The **`Navigator.vibrate()`** method pulses the vibration
The **`vibrate()`** method of the {{domxref("navigator")}} interface pulses the vibration
skyclouds2001 marked this conversation as resolved.
Show resolved Hide resolved
hardware on the device, if such hardware exists. If the device doesn't support
vibration, this method has no effect. If a vibration pattern is already in progress when
this method is called, the previous pattern is halted and the new one begins instead.
Expand Down
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