├── .github └── workflows │ └── auto-publish.yml ├── .pr-preview.json ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── index.html ├── releases ├── CR.html ├── CR2-diff.html ├── CR2.html ├── CR2.src.html ├── CR3-diff.html ├── CR3.html ├── CR3.src.html ├── FPWD.html ├── LC.html ├── LC2.html ├── LC2.src.html ├── LC3.html ├── LC3.src.html ├── LC4-diff.html ├── LC4.html ├── LC4.src.html ├── Overview-diff.html ├── PER-diff.html ├── PER.html ├── PER.src.html ├── PR-diff.html ├── PR.html └── PR.src.html └── w3c.json /.github/workflows/auto-publish.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/w3c/spec-prod/blob/main/docs/examples.md#use-different-respecconfig-when-deploying-to-w3c 2 | 3 | name: CI 4 | on: 5 | pull_request: {} 6 | push: 7 | branches: [gh-pages] 8 | jobs: 9 | main: 10 | name: Build, Validate and Deploy 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: w3c/spec-prod@v2 15 | with: 16 | TOOLCHAIN: respec 17 | W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN }} 18 | W3C_WG_DECISION_URL: https://lists.w3.org/Archives/Public/public-device-apis/2021May/0008.html 19 | # Publish to w3.org/TR as a Candidate Recommendation Draft (CRD) 20 | W3C_BUILD_OVERRIDE: | 21 | specStatus: CRD 22 | shortName: vibration -------------------------------------------------------------------------------- /.pr-preview.json: -------------------------------------------------------------------------------- 1 | { 2 | "src_file": "index.html", 3 | "type": "respec" 4 | } 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributions to this repository are intended to become part of Recommendation-track documents governed by the 2 | [W3C Patent Policy](http://www.w3.org/Consortium/Patent-Policy-20040205/) and 3 | [Document License](http://www.w3.org/Consortium/Legal/copyright-documents). To make substantive contributions to specifications, you must either participate 4 | in the relevant W3C Working Group or make a non-member patent licensing commitment. 5 | 6 | If you are not the sole contributor to a contribution (pull request), please identify all 7 | contributors in the pull request comment. 8 | 9 | To add a contributor (other than yourself, that's automatic), mark them one per line as follows: 10 | 11 | ``` 12 | +@github_username 13 | ``` 14 | 15 | If you added a contributor by mistake, you can remove them in a comment with: 16 | 17 | ``` 18 | -@github_username 19 | ``` 20 | 21 | If you are making a pull request on behalf of someone else but you had no part in designing the 22 | feature, you can remove yourself with the above syntax. 23 | 24 | # Tests 25 | 26 | For normative changes, a corresponding 27 | [web-platform-tests](https://github.com/web-platform-tests/wpt) PR is highly appreciated. Typically, 28 | both PRs will be merged at the same time. Note that a test change that contradicts the spec should 29 | not be merged before the corresponding spec change. If testing is not practical, please explain why 30 | and if appropriate [file a web-platform-tests issue](https://github.com/web-platform-tests/wpt/issues/new) 31 | to follow up later. Add the `type:untestable` or `type:missing-coverage` label as appropriate. 32 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | All documents in this Repository are licensed by contributors 2 | under the 3 | [W3C Document License](http://www.w3.org/Consortium/Legal/copyright-documents). 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Vibration API 2 | 3 | This repository contains the [Vibration API](https://w3c.github.io/vibration/) 4 | specification. -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |53 | This document represents the consensus of the group on the scope and 54 | features of the Vibration API. It should be noted that the group is 55 | aware of more advanced use cases that cannot be realized using this 56 | simpler first version. The intent is to address them in a future 57 | revision. 58 |
59 |60 | A history of changes from previous version is provided. 61 |
62 |68 | The API is specifically designed to address use cases that require 69 | simple tactile feedback only. Use cases requiring more fine-grained 70 | control are out of scope for this specification. This API is not meant 71 | to be used as a generic notification mechanism. Such use cases may be 72 | handled using the Notifications API [[NOTIFICATIONS]] 73 | specification. In addition, determining whether vibration is enabled is 74 | out of scope for this specification. 75 |
76 |79 | This specification defines conformance criteria that apply to a single 80 | product: the user agent that implements the 81 | interfaces that it contains. 82 |
83 |84 | Implementations that use ECMAScript to implement the APIs defined in 85 | this specification must implement them in a manner consistent with the 86 | ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL-1]], 87 | as this specification uses that specification and terminology. 88 |
89 |95 | typedef (unsigned long or sequence<unsigned long>) VibratePattern; 96 | 97 | partial interface Navigator { 98 | boolean vibrate (VibratePattern pattern); 99 | }; 100 |101 |
102 | The vibrate()
method
103 | steps are to run the processing vibration patterns algorithm.
104 | A vibration pattern is represented by a
105 | VibratePattern
object.
106 |
108 | The rules for processing vibration patterns are as given in 109 | the following algorithm: 110 |
111 |vibrate()
method.
114 | visible
, then return false and terminate these steps.
120 | 133 | To validate and normalize a vibration pattern given 134 | pattern, run these steps: 135 |
136 |169 | To perform vibration using a global object 170 | global and a vibration pattern pattern, 171 | run these steps: 172 |
173 |
214 | When the user agent determines that
215 | the [=Document/visibility state=] of
216 | the Document
of the top-level browsing
217 | context changes, it MUST abort the already running processing
218 | vibration patterns algorithm, if any.
219 |
226 | Vibration API is not a source of data on its own and as such is not 227 | producing any data possible to consume on the Web. However, it is known 228 | that it can serve as a source of events for other APIs. In particular, 229 | it is known that certain sensors such as accelerometers or gyroscopes 230 | are prone to tiny imperfections during their manufacturing. As such, 231 | they provide a fingerprinting surface that can be exploited utilizing 232 | the vibration stimuli generated via the Vibration API. In this sense, 233 | Vibration API provides an indirect privacy risk, in conjunction with 234 | other mechanisms. This can create possibly unexpected privacy risks, 235 | including cross-device tracking and communication. Additionally, a 236 | device that is vibrating might be visible to external observers and 237 | enable physical identification, and possibly tracking of the user. 238 |
239 |240 | For these reasons, the user agent MAY inform the user when 241 | the API is being used and provide a mechanism to disable the API 242 | (effectively no-op), on a per-origin basis or globally. 243 |
244 |245 | The user agent SHOULD employ global rate limiting to restrict 246 | the number of vibration requests made within a certain period 247 | (e.g., per minute or hour) to prevent excessive use. 248 |
249 |255 | In the following example the device will vibrate for 1000 milliseconds 256 | (ms): 257 |
258 |259 | // vibrate for 1000 ms 260 | navigator.vibrate(1000); 261 | 262 | // or alternatively 263 | navigator.vibrate([1000]); 264 |265 |
266 | In the following example the pattern will cause the device to vibrate 267 | for 50 ms, be still for 100 ms, and then vibrate for 150 ms: 268 |
269 |270 | navigator.vibrate([50, 100, 150]); 271 |272 |
273 | The following example cancels any existing vibrations: 274 |
275 |276 | // cancel any existing vibrations 277 | navigator.vibrate(0); 278 | 279 | // or alternatively 280 | navigator.vibrate([]); 281 |282 |
288 | The group is deeply indebted to Justin Lebar, Mounir Lamouri, Jonas 289 | Sicking, and the Mozilla WebAPI team for their contributions, and for 290 | providing the WebVibrator prototype as an initial input. Thanks to Anne 291 | van Kesteren for suggestions on how to make the specification reusable 292 | in other contexts, and to Lukasz Olejnik for the privacy 293 | considerations. Finally, thanks to Zhiqiang Zhang for the Simplified 294 | Chinese translation. 295 |
296 |302 | Changes since W3C Recommendation 18 October 2016: 303 |
304 |317 | Other changes that do not functionally affect interpretation of the document: 318 |
319 |Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
477 | This specification defines an API that provides access to the vibration 478 | mechanism of the hosting device. Vibration is a form of tactile feedback. 479 |
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
480 |481 | This document represents the consensus of the group on the scope and features of the 482 | Vibration API. It should be noted that the group is aware of more advanced use cases that cannot 483 | be realised using this simpler first version. The intent is to address them in a future revision. 484 |
485 |This document was published by the Device APIs Working Group as a Candidate Recommendation. This document is intended to become a W3C Recommendation. If you wish to make comments regarding this document, please send them to public-device-apis@w3.org (subscribe, archives). W3C publishes a Candidate Recommendation to indicate that the document is believed to be stable and to encourage implementation by the developer community. This Candidate Recommendation is expected to advance to Proposed Recommendation no earlier than 01 July 2012. All feedback is welcome.
Publication as a Candidate Recommendation does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This section is non-normative.
491 |492 | The Vibration API defines a means for web developers to 493 | programmatically provide tactile feedback in the form of vibration. The 494 | API is designed to tackle high-value use cases related to gaming, and 495 | is not meant to be used as a generic notification mechanism. 496 |
497 |As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
500 |The key words must, must not, required, should, should not, recommended, may, and optional in this specification are to be interpreted as described in [RFC2119].
501 | 502 |503 | This specification defines conformance criteria that apply to a single 504 | product: the user agent that implements the 505 | interfaces that it contains. 506 |
507 |508 | Implementations that use ECMAScript to implement the APIs defined in 509 | this specification must implement them in a manner consistent with the 510 | ECMAScript Bindings defined in the Web IDL specification [WEBIDL], 511 | as this specification uses that specification and terminology. 512 |
513 |Navigator implements Vibration
;
518 | interface Vibration {
519 | void vibrate (unsigned long time);
520 | void vibrate (unsigned long[] pattern);
521 | };
522 |
vibrate
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
time | unsigned long | ✘ | ✘ | 525 | Vibration time in milliseconds. 526 | |
void
vibrate
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
pattern | unsigned long[] | ✘ | ✘ | 529 | A vibration pattern represented by a list of time entries. 530 | Odd entries represent vibration time in milliseconds, even 531 | entries still periods in milliseconds between the vibrations. 532 | |
void
535 | The vibrate()
method, when invoked, must run the algorithm
536 | for processing vibration patterns.
537 |
539 | The rules for processing vibration patterns are as given in 540 | the following algorithm: 541 |
542 |
551 |
552 | hidden
attribute [PAGE-VISIBILITY] is set to true,
553 | abort these steps.
554 | NotSupportedError
exception [DOM4] and abort these
584 | steps.
585 | NotSupportedError
exception [DOM4] and
594 | abort these steps.
595 |
629 | When the
630 |
631 | visibilitychange
event [PAGE-VISIBILITY] is dispatched at
632 | the Document
, the user
633 | agent must run the following steps:
634 |
638 | hidden
attribute [PAGE-VISIBILITY] is set to true,
639 | the user agent must suppress
640 | the vibration produced by running the pre-existing instance of the
641 | processing vibration patterns algorithm, if any.
642 |
645 | hidden
attribute [PAGE-VISIBILITY] is set to false,
646 | the user agent must restore
647 | the vibration produced by running the pre-existing instance of the processing vibration
648 | patterns algorithm, if any.
649 |
652 | If the device does not provide a vibration mechanism, or it is
653 | disabled, the user agent must
654 | silently ignore any invocations of the vibrate()
method.
655 |
This section is non-normative.
660 |661 | In the following example the device vibrates for 1 second: 662 |
// vibrate for 1 second 664 | navigator.vibrate(1000); 665 | 666 | // or alternatively 667 | navigator.vibrate([1000]);668 |
670 | In the following example the device vibrates for 1 second, is still for 671 | 0.5 seconds, and vibrates again for 2 seconds: 672 |
673 |navigator.vibrate([1000, 500, 2000]);675 |
677 |
678 | The following example cancels any existing vibrations: 679 |
680 |navigator.vibrate(0); 682 | 683 | // or alternatively 684 | navigator.vibrate([]);685 |
690 | The group is deeply indebted to Mounir Lamouri, Jonas Sicking, and 691 | the Mozilla WebAPI team in general for providing the WebVibrator 692 | prototype as an initial input. 693 |
694 |No informative references.
467 | Copyright © 468 | 2013 469 | 470 | W3C® 471 | (MIT, 472 | ERCIM, 473 | Keio, Beihang), All Rights Reserved. 474 | W3C liability, 475 | trademark and 476 | document use rules apply. 477 |
478 | 479 | 480 |483 | This specification defines an API that provides access to the vibration 484 | mechanism of the hosting device. Vibration is a form of tactile feedback. 485 |
490 | This section describes the status of this document at the time of its publication. Other 491 | documents may supersede this document. A list of current W3C publications and the latest revision 492 | of this technical report can be found in the W3C technical reports 493 | index at http://www.w3.org/TR/. 494 |
495 | 496 |497 | The following changes 498 | (disposition of comments, 499 | redline) have been made 500 | since the 501 | W3C Last Call Working Draft 23 May 2013: 502 |
503 |517 | Before this specification 518 | exits Candidate Recommendation, two or more independent deployed 519 | implementations must demonstrate interoperability of each 520 | feature. No features have been marked as 'at risk'. 521 | The group will create an Implementation 522 | Report. 523 |
524 |525 | This document represents the consensus of the group on the scope and 526 | features of the Vibration API. It should be noted that the group is 527 | aware of more advanced use cases that cannot be realized using this 528 | simpler first version. The intent is to address them in a future 529 | revision. 530 |
531 | 532 |533 | This document was published by the Device APIs Working Group as a Candidate Recommendation. 534 | 535 | This document is intended to become a W3C Recommendation. 536 | 537 | 538 | If you wish to make comments regarding this document, please send them to 539 | public-device-apis@w3.org 540 | (subscribe, 541 | archives). 542 | 543 | 544 | 545 | W3C publishes a Candidate Recommendation to indicate that the document is believed 546 | to be stable and to encourage implementation by the developer community. This 547 | Candidate Recommendation is expected to advance to Proposed Recommendation no earlier than 548 | 18 September 2013. 549 | 550 | 551 | All comments are welcome.
552 | 553 | 554 |555 | Publication as a Candidate Recommendation does not imply endorsement by the W3C Membership. 556 | This is a draft document and may be updated, replaced or obsoleted by other documents at 557 | any time. It is inappropriate to cite this document as other than work in progress. 558 |
559 | 560 | 561 |562 | 563 | This document was produced by a group operating under the 564 | 565 | 5 February 2004 W3C Patent Policy. 566 | 567 | 568 | 569 | 570 | 571 | W3C maintains a public list of any patent disclosures 572 | 573 | made in connection with the deliverables of the group; that page also includes instructions for 574 | disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains 575 | Essential Claim(s) must disclose the 576 | information in accordance with section 577 | 6 of the W3C Patent Policy. 578 | 579 | 580 |
581 | 582 | 583 | 584 | 585 |This section is non-normative.
591 |592 | The API is specifically designed to address use cases that require 593 | simple tactile feedback only. Use cases requiring more fine-grained 594 | control are out of scope for this specification. This API is not meant 595 | to be used as a generic notification mechanism. Such use cases may be 596 | handled using the Web Notifications [notifications] 597 | specification. In addition, determining whether vibration is enabled 598 | is out of scope for this specification. 599 |
600 |604 | As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, 605 | and notes in this specification are non-normative. Everything else in this specification is 606 | normative. 607 |
608 |609 | The key words MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT, RECOMMENDED, MAY, 610 | and OPTIONAL in this specification are to be interpreted as described in [RFC2119]. 611 |
612 | 613 |614 | This specification defines conformance criteria that apply to a single 615 | product: the user agent that implements the 616 | interfaces that it contains. 617 |
618 |619 | Implementations that use ECMAScript to implement the APIs defined in 620 | this specification must implement them in a manner consistent with the 621 | ECMAScript Bindings defined in the Web IDL specification [WEBIDL], 622 | as this specification uses that specification and terminology. 623 |
624 |629 | The concepts 630 | browsing context and 631 | 632 | spin the event loop are defined in [HTML5]. 633 |
634 |
641 |
642 |
643 | The vibrate()
644 | method, when invoked, MUST run the algorithm
645 | for processing vibration patterns.
646 |
648 | The rules for processing vibration patterns are as given in 649 | the following algorithm: 650 |
651 |
684 |
685 | hidden
attribute [PAGE-VISIBILITY] is set to true,
686 | then return false and terminate these steps.
687 |
732 | When the
733 |
734 | visibilitychange
event [PAGE-VISIBILITY] is dispatched at
735 | the Document
in a browsing context, the
736 | user agent MUST cancel the
737 | pre-existing instance of the processing vibration patterns
738 | algorithm, if any.
739 |
This section is non-normative.
744 |745 | In the following example the device will vibrate for 1000 milliseconds (ms): 746 |
// vibrate for 1000 ms 747 | navigator.vibrate(1000); 748 | 749 | // or alternatively 750 | navigator.vibrate([1000]);
752 | In the following example the pattern will cause the device to vibrate 753 | for 50 ms, be still for 100 ms, and then vibrate for 150 ms: 754 |
755 |navigator.vibrate([50, 100, 150]);
757 |
758 | The following example cancels any existing vibrations: 759 |
760 |// cancel any existing vibrations 761 | navigator.vibrate(0); 762 | 763 | // or alternatively 764 | navigator.vibrate([]);
769 | The group is deeply indebted to Justin Lebar, Mounir Lamouri, Jonas 770 | Sicking, and the Mozilla WebAPI team for their contributions, and for 771 | providing the WebVibrator prototype as an initial input. 772 |
773 |40 | The following changes 41 | (disposition of comments, 42 | redline) have been made 43 | since the 44 | W3C Last Call Working Draft 23 May 2013: 45 |
46 |60 | Before this specification 61 | exits Candidate Recommendation, two or more independent deployed 62 | implementations must demonstrate interoperability of each 63 | feature. No features have been marked as 'at risk'. 64 | The group will create an Implementation 65 | Report. 66 |
67 |68 | This document represents the consensus of the group on the scope and 69 | features of the Vibration API. It should be noted that the group is 70 | aware of more advanced use cases that cannot be realized using this 71 | simpler first version. The intent is to address them in a future 72 | revision. 73 |
74 |79 | The API is specifically designed to address use cases that require 80 | simple tactile feedback only. Use cases requiring more fine-grained 81 | control are out of scope for this specification. This API is not meant 82 | to be used as a generic notification mechanism. Such use cases may be 83 | handled using the Web Notifications [[notifications]] 84 | specification. In addition, determining whether vibration is enabled 85 | is out of scope for this specification. 86 |
87 |91 | This specification defines conformance criteria that apply to a single 92 | product: the user agent that implements the 93 | interfaces that it contains. 94 |
95 |96 | Implementations that use ECMAScript to implement the APIs defined in 97 | this specification must implement them in a manner consistent with the 98 | ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], 99 | as this specification uses that specification and terminology. 100 |
101 |106 | The concepts 107 | browsing context and 108 | 109 | spin the event loop are defined in [[!HTML5]]. 110 |
111 |
126 | The vibrate()
127 | method, when invoked, MUST run the algorithm
128 | for processing vibration patterns.
129 |
131 | The rules for processing vibration patterns are as given in 132 | the following algorithm: 133 |
134 |
167 |
168 | hidden
attribute [[!PAGE-VISIBILITY]] is set to true,
169 | then return false and terminate these steps.
170 |
215 | When the
216 |
217 | visibilitychange
event [[!PAGE-VISIBILITY]] is dispatched at
218 | the Document
in a browsing context, the
219 | user agent MUST cancel the
220 | pre-existing instance of the processing vibration patterns
221 | algorithm, if any.
222 |
228 | In the following example the device will vibrate for 1000 milliseconds (ms): 229 |
230 | // vibrate for 1000 ms 231 | navigator.vibrate(1000); 232 | 233 | // or alternatively 234 | navigator.vibrate([1000]); 235 |236 |
237 | In the following example the pattern will cause the device to vibrate 238 | for 50 ms, be still for 100 ms, and then vibrate for 150 ms: 239 |
240 |241 | navigator.vibrate([50, 100, 150]); 242 |243 |
244 |
245 | The following example cancels any existing vibrations: 246 |
247 |248 | // cancel any existing vibrations 249 | navigator.vibrate(0); 250 | 251 | // or alternatively 252 | navigator.vibrate([]); 253 |254 |
258 | The group is deeply indebted to Justin Lebar, Mounir Lamouri, Jonas 259 | Sicking, and the Mozilla WebAPI team for their contributions, and for 260 | providing the WebVibrator prototype as an initial input. 261 |
262 |40 | The following changes have been made 41 | since the 42 | W3C Last Call Working Draft 19 June 2014 43 | (diff): 44 |
45 |53 | The CR exit criterion is two interoperable deployed implementations of 54 | each feature. No features are marked as 'at-risk'. The group will create 55 | an 56 | Implementation Report. 57 |
58 |59 | This document represents the consensus of the group on the scope and 60 | features of the Vibration API. It should be noted that the group is 61 | aware of more advanced use cases that cannot be realized using this 62 | simpler first version. The intent is to address them in a future 63 | revision. 64 |
65 |70 | The API is specifically designed to address use cases that require 71 | simple tactile feedback only. Use cases requiring more fine-grained 72 | control are out of scope for this specification. This API is not meant 73 | to be used as a generic notification mechanism. Such use cases may be 74 | handled using the Web Notifications [[notifications]] 75 | specification. In addition, determining whether vibration is enabled 76 | is out of scope for this specification. 77 |
78 |82 | This specification defines conformance criteria that apply to a single 83 | product: the user agent that implements the 84 | interfaces that it contains. 85 |
86 |87 | Implementations that use ECMAScript to implement the APIs defined in 88 | this specification must implement them in a manner consistent with the 89 | ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], 90 | as this specification uses that specification and terminology. 91 |
92 |97 | The concepts 98 | browsing context and 99 | 100 | spin the event loop are defined in [[!HTML5]]. 101 |
102 |
117 | The vibrate()
118 | method, when invoked, MUST run the algorithm
119 | for processing vibration patterns.
120 |
122 | The rules for processing vibration patterns are as given in 123 | the following algorithm: 124 |
125 |
180 |
181 | hidden
attribute [[!PAGE-VISIBILITY]] is set to true,
182 | then return false and terminate these steps.
183 |
234 | When the
235 |
236 | visibilitychange
event [[!PAGE-VISIBILITY]] is dispatched at
237 | the Document
in a browsing context, the
238 | user agent MUST cancel the
239 | pre-existing instance of the processing vibration patterns
240 | algorithm, if any.
241 |
247 | In the following example the device will vibrate for 1000 milliseconds (ms): 248 |
249 | // vibrate for 1000 ms 250 | navigator.vibrate(1000); 251 | 252 | // or alternatively 253 | navigator.vibrate([1000]); 254 |255 |
256 | In the following example the pattern will cause the device to vibrate 257 | for 50 ms, be still for 100 ms, and then vibrate for 150 ms: 258 |
259 |260 | navigator.vibrate([50, 100, 150]); 261 |262 |
263 |
264 | The following example cancels any existing vibrations: 265 |
266 |267 | // cancel any existing vibrations 268 | navigator.vibrate(0); 269 | 270 | // or alternatively 271 | navigator.vibrate([]); 272 |273 |
277 | The group is deeply indebted to Justin Lebar, Mounir Lamouri, Jonas 278 | Sicking, and the Mozilla WebAPI team for their contributions, and for 279 | providing the WebVibrator prototype as an initial input. 280 |
281 |465 | Copyright © 466 | 2013 467 | 468 | W3C® 469 | (MIT, 470 | ERCIM, 471 | Keio, Beihang), All Rights Reserved. 472 | W3C liability, 473 | trademark and 474 | document use rules apply. 475 |
476 | 477 | 478 |481 | This specification defines an API that provides access to the vibration 482 | mechanism of the hosting device. Vibration is a form of tactile feedback. 483 |
488 | This section describes the status of this document at the time of its publication. Other 489 | documents may supersede this document. A list of current W3C publications and the latest revision 490 | of this technical report can be found in the W3C technical reports 491 | index at http://www.w3.org/TR/. 492 |
493 | 494 |495 | The changes made since the 496 | 08 May 2012 W3C Candidate Recommendation (diff): 497 |
498 |vibrate()
501 | method's return type from void to boolean, use sequence type for
502 | the pattern attribute, make the interface partial
503 | 510 | This document represents the consensus of the group on the scope and 511 | features of the Vibration API. It should be noted that the group is 512 | aware of more advanced use cases that cannot be realized using this 513 | simpler first version. The intent is to address them in a future 514 | revision. 515 |
516 | 517 |518 | This document was published by the Device APIs Working Group as a Last Call Working Draft. 519 | 520 | This document is intended to become a W3C Recommendation. 521 | 522 | 523 | If you wish to make comments regarding this document, please send them to 524 | public-device-apis@w3.org 525 | (subscribe, 526 | archives). 527 | 528 | The Last Call period ends 13 June 2013. 529 | 530 | 531 | All comments are welcome. 532 | 533 | 534 |
535 | Publication as a Last Call Working Draft does not imply endorsement by the W3C Membership. 536 | This is a draft document and may be updated, replaced or obsoleted by other documents at 537 | any time. It is inappropriate to cite this document as other than work in progress. 538 |
539 | 540 | 541 |542 | This is a Last Call Working Draft and thus the Working Group has determined that this document has satisfied the 543 | relevant technical requirements and is sufficiently stable to advance through the Technical Recommendation process. 544 |
545 | 546 |547 | 548 | This document was produced by a group operating under the 549 | 5 February 2004 W3C Patent Policy. 550 | 551 | 552 | 553 | 554 | W3C maintains a public list of any patent disclosures 555 | 556 | made in connection with the deliverables of the group; that page also includes instructions for 557 | disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains 558 | Essential Claim(s) must disclose the 559 | information in accordance with section 560 | 6 of the W3C Patent Policy. 561 | 562 | 563 |
564 | 565 | 566 | 567 | 568 |This section is non-normative.
574 |575 | The API is specifically designed to address use cases that require 576 | simple tactile feedback only. Use cases requiring more fine-grained 577 | control are out of scope for this specification. In addition, the API 578 | is not meant to be used as a generic notification mechanism. 579 |
580 |584 | As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, 585 | and notes in this specification are non-normative. Everything else in this specification is 586 | normative. 587 |
588 |589 | The key words MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT, RECOMMENDED, MAY, 590 | and OPTIONAL in this specification are to be interpreted as described in [RFC2119]. 591 |
592 | 593 |594 | This specification defines conformance criteria that apply to a single 595 | product: the user agent that implements the 596 | interfaces that it contains. 597 |
598 |599 | Implementations that use ECMAScript to implement the APIs defined in 600 | this specification must implement them in a manner consistent with the 601 | ECMAScript Bindings defined in the Web IDL specification [WEBIDL], 602 | as this specification uses that specification and terminology. 603 |
604 |609 | The concepts 610 | browsing context and 611 | 612 | spin the event loop are defined in [HTML5]. 613 |
614 |
621 |
622 |
623 | The vibrate()
624 | method, when invoked, MUST run the algorithm
625 | for processing vibration patterns.
626 |
628 | The rules for processing vibration patterns are as given in 629 | the following algorithm: 630 |
631 |
664 |
665 | hidden
attribute [PAGE-VISIBILITY] is set to true,
666 | then return false and terminate these steps.
667 |
712 | When the
713 |
714 | visibilitychange
event [PAGE-VISIBILITY] is dispatched at
715 | the Document
in a browsing context, the
716 | user agent MUST cancel the
717 | pre-existing instance of the processing vibration patterns
718 | algorithm, if any.
719 |
This section is non-normative.
724 |725 | In the following example the device will vibrate for 1000 milliseconds (ms): 726 |
// vibrate for 1000 ms 727 | navigator.vibrate(1000); 728 | 729 | // or alternatively 730 | navigator.vibrate([1000]);
732 | In the following example the pattern will cause the device to vibrate 733 | for 50 ms, be still for 100 ms, and then vibrate for 150 ms: 734 |
735 |navigator.vibrate([50, 100, 150]);
737 |
738 | The following example cancels any existing vibrations: 739 |
740 |// cancel any existing vibrations 741 | navigator.vibrate(0); 742 | 743 | // or alternatively 744 | navigator.vibrate([]);
749 | The group is deeply indebted to Justin Lebar, Mounir Lamouri, Jonas 750 | Sicking, and the Mozilla WebAPI team for their contributions, and for 751 | providing the WebVibrator prototype as an initial input. 752 |
753 |38 | The changes made since the 39 | 08 May 2012 W3C Candidate Recommendation (diff): 40 |
41 |vibrate()
44 | method's return type from void to boolean, use sequence type for
45 | the pattern attribute, make the interface partial
46 | 53 | This document represents the consensus of the group on the scope and 54 | features of the Vibration API. It should be noted that the group is 55 | aware of more advanced use cases that cannot be realized using this 56 | simpler first version. The intent is to address them in a future 57 | revision. 58 |
59 |64 | The API is specifically designed to address use cases that require 65 | simple tactile feedback only. Use cases requiring more fine-grained 66 | control are out of scope for this specification. In addition, the API 67 | is not meant to be used as a generic notification mechanism. 68 |
69 |73 | This specification defines conformance criteria that apply to a single 74 | product: the user agent that implements the 75 | interfaces that it contains. 76 |
77 |78 | Implementations that use ECMAScript to implement the APIs defined in 79 | this specification must implement them in a manner consistent with the 80 | ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], 81 | as this specification uses that specification and terminology. 82 |
83 |88 | The concepts 89 | browsing context and 90 | 91 | spin the event loop are defined in [[!HTML5]]. 92 |
93 |
108 | The vibrate()
method, when invoked, MUST run the algorithm
109 | for processing vibration patterns.
110 |
112 | The rules for processing vibration patterns are as given in 113 | the following algorithm: 114 |
115 |
148 |
149 | hidden
attribute [[!PAGE-VISIBILITY]] is set to true,
150 | then return false and terminate these steps.
151 |
196 | When the
197 |
198 | visibilitychange
event [[!PAGE-VISIBILITY]] is dispatched at
199 | the Document
in a browsing context, the
200 | user agent MUST cancel the
201 | pre-existing instance of the processing vibration patterns
202 | algorithm, if any.
203 |
209 | In the following example the device will vibrate for 1000 milliseconds (ms): 210 |
211 | // vibrate for 1000 ms 212 | navigator.vibrate(1000); 213 | 214 | // or alternatively 215 | navigator.vibrate([1000]); 216 |217 |
218 | In the following example the pattern will cause the device to vibrate 219 | for 50 ms, be still for 100 ms, and then vibrate for 150 ms: 220 |
221 |222 | navigator.vibrate([50, 100, 150]); 223 |224 |
225 |
226 | The following example cancels any existing vibrations: 227 |
228 |229 | // cancel any existing vibrations 230 | navigator.vibrate(0); 231 | 232 | // or alternatively 233 | navigator.vibrate([]); 234 |235 |
239 | The group is deeply indebted to Justin Lebar, Mounir Lamouri, Jonas 240 | Sicking, and the Mozilla WebAPI team for their contributions, and for 241 | providing the WebVibrator prototype as an initial input. 242 |
243 |45 | The following changes have been made 46 | since the 47 | W3C Candidate Recommendation 23 July 2013: 48 |
49 |68 | This document represents the consensus of the group on the scope and 69 | features of the Vibration API. It should be noted that the group is 70 | aware of more advanced use cases that cannot be realized using this 71 | simpler first version. The intent is to address them in a future 72 | revision. 73 |
74 |79 | The API is specifically designed to address use cases that require 80 | simple tactile feedback only. Use cases requiring more fine-grained 81 | control are out of scope for this specification. This API is not meant 82 | to be used as a generic notification mechanism. Such use cases may be 83 | handled using the Web Notifications [[notifications]] 84 | specification. In addition, determining whether vibration is enabled 85 | is out of scope for this specification. 86 |
87 |91 | This specification defines conformance criteria that apply to a single 92 | product: the user agent that implements the 93 | interfaces that it contains. 94 |
95 |96 | Implementations that use ECMAScript to implement the APIs defined in 97 | this specification must implement them in a manner consistent with the 98 | ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], 99 | as this specification uses that specification and terminology. 100 |
101 |106 | The concepts 107 | browsing context and 108 | 109 | spin the event loop are defined in [[!HTML5]]. 110 |
111 |
126 | The vibrate()
127 | method, when invoked, MUST run the algorithm
128 | for processing vibration patterns.
129 |
131 | The rules for processing vibration patterns are as given in 132 | the following algorithm: 133 |
134 |
188 |
189 | hidden
attribute [[!PAGE-VISIBILITY]] is set to true,
190 | then return false and terminate these steps.
191 |
241 | When the
242 |
243 | visibilitychange
event [[!PAGE-VISIBILITY]] is dispatched at
244 | the Document
in a browsing context, the
245 | user agent MUST cancel the
246 | pre-existing instance of the processing vibration patterns
247 | algorithm, if any.
248 |
254 | In the following example the device will vibrate for 1000 milliseconds (ms): 255 |
256 | // vibrate for 1000 ms 257 | navigator.vibrate(1000); 258 | 259 | // or alternatively 260 | navigator.vibrate([1000]); 261 |262 |
263 | In the following example the pattern will cause the device to vibrate 264 | for 50 ms, be still for 100 ms, and then vibrate for 150 ms: 265 |
266 |267 | navigator.vibrate([50, 100, 150]); 268 |269 |
270 |
271 | The following example cancels any existing vibrations: 272 |
273 |274 | // cancel any existing vibrations 275 | navigator.vibrate(0); 276 | 277 | // or alternatively 278 | navigator.vibrate([]); 279 |280 |
284 | The group is deeply indebted to Justin Lebar, Mounir Lamouri, Jonas 285 | Sicking, and the Mozilla WebAPI team for their contributions, and for 286 | providing the WebVibrator prototype as an initial input. 287 |
288 |45 | The following changes have been made 46 | since the 47 | W3C Last Call Working Draft 11 February 2014 48 | (diff): 49 |
50 |60 | This document represents the consensus of the group on the scope and 61 | features of the Vibration API. It should be noted that the group is 62 | aware of more advanced use cases that cannot be realized using this 63 | simpler first version. The intent is to address them in a future 64 | revision. 65 |
66 |71 | The API is specifically designed to address use cases that require 72 | simple tactile feedback only. Use cases requiring more fine-grained 73 | control are out of scope for this specification. This API is not meant 74 | to be used as a generic notification mechanism. Such use cases may be 75 | handled using the Web Notifications [[notifications]] 76 | specification. In addition, determining whether vibration is enabled 77 | is out of scope for this specification. 78 |
79 |83 | This specification defines conformance criteria that apply to a single 84 | product: the user agent that implements the 85 | interfaces that it contains. 86 |
87 |88 | Implementations that use ECMAScript to implement the APIs defined in 89 | this specification must implement them in a manner consistent with the 90 | ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], 91 | as this specification uses that specification and terminology. 92 |
93 |98 | The concepts 99 | browsing context and 100 | 101 | spin the event loop are defined in [[!HTML5]]. 102 |
103 |
118 | The vibrate()
119 | method, when invoked, MUST run the algorithm
120 | for processing vibration patterns.
121 |
123 | The rules for processing vibration patterns are as given in 124 | the following algorithm: 125 |
126 |
181 |
182 | hidden
attribute [[!PAGE-VISIBILITY]] is set to true,
183 | then return false and terminate these steps.
184 |
234 | When the
235 |
236 | visibilitychange
event [[!PAGE-VISIBILITY]] is dispatched at
237 | the Document
in a browsing context, the
238 | user agent MUST cancel the
239 | pre-existing instance of the processing vibration patterns
240 | algorithm, if any.
241 |
247 | In the following example the device will vibrate for 1000 milliseconds (ms): 248 |
249 | // vibrate for 1000 ms 250 | navigator.vibrate(1000); 251 | 252 | // or alternatively 253 | navigator.vibrate([1000]); 254 |255 |
256 | In the following example the pattern will cause the device to vibrate 257 | for 50 ms, be still for 100 ms, and then vibrate for 150 ms: 258 |
259 |260 | navigator.vibrate([50, 100, 150]); 261 |262 |
263 |
264 | The following example cancels any existing vibrations: 265 |
266 |267 | // cancel any existing vibrations 268 | navigator.vibrate(0); 269 | 270 | // or alternatively 271 | navigator.vibrate([]); 272 |273 |
277 | The group is deeply indebted to Justin Lebar, Mounir Lamouri, Jonas 278 | Sicking, and the Mozilla WebAPI team for their contributions, and for 279 | providing the WebVibrator prototype as an initial input. 280 |
281 |85 | The following editorial changes were made since the W3C Recommendation 87 | 10 February 2015 (diff): 88 |
89 |108 | The API is specifically designed to address use cases that require 109 | simple tactile feedback only. Use cases requiring more fine-grained 110 | control are out of scope for this specification. This API is not meant 111 | to be used as a generic notification mechanism. Such use cases may be 112 | handled using the Notifications API [[NOTIFICATIONS]] 113 | specification. In addition, determining whether vibration is enabled is 114 | out of scope for this specification. 115 |
116 |119 | This specification defines conformance criteria that apply to a single 120 | product: the user agent that implements the 121 | interfaces that it contains. 122 |
123 |124 | Implementations that use ECMAScript to implement the APIs defined in 125 | this specification must implement them in a manner consistent with the 126 | ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL-1]], 127 | as this specification uses that specification and terminology. 128 |
129 |135 | The concepts top-level 137 | browsing context and spin 139 | the event loop are defined in [[!HTML5]]. 140 |
141 |147 | typedef (unsigned long or sequence<unsigned long>) VibratePattern; 148 | 149 | partial interface Navigator { 150 | boolean vibrate (VibratePattern pattern); 151 | }; 152 |153 |
154 | The vibrate()
method, when invoked, MUST run the
155 | algorithm for processing vibration patterns.
156 |
158 | The rules for processing vibration patterns are as given in 159 | the following algorithm: 160 |
161 |vibrate()
method.
164 | visible
, then return false and terminate these steps.
172 | 184 | To validate and normalize a vibration pattern given 185 | pattern, run these steps: 186 |
187 |235 | To perform vibration using pattern, run these 236 | steps: 237 |
238 |
275 | When the user agent determines that the visibility
277 | state of the Document
of the top-level browsing
278 | context changes, it MUST abort the already running processing
279 | vibration patterns algorithm, if any.
280 |
287 | Vibration API is not a source of data on its own and as such is not 288 | producing any data possible to consume on the Web. However, it is known 289 | that it can serve as a source of events for other APIs. In particular, 290 | it is known that certain sensors such as accelerometers or gyroscopes 291 | are prone to tiny imperfections during their manufacturing. As such, 292 | they provide a fingerprinting surface that can be exploited utilizing 293 | the vibration stimuli generated via the Vibration API. In this sense, 294 | Vibration API provides an indirect privacy risk, in conjunction with 295 | other mechanisms. This can create possibly unexpected privacy risks, 296 | including cross-device tracking and communication. Additionally, a 297 | device that is vibrating might be visible to external observers and 298 | enable physical identification, and possibly tracking of the user. 299 |
300 |301 | For these reasons, the user agent SHOULD inform the user when the API 302 | is being used and provide a mechanism to disable the API (effectively 303 | no-op), on a per-origin basis or globally. 304 |
305 |311 | In the following example the device will vibrate for 1000 milliseconds 312 | (ms): 313 |
314 |315 | // vibrate for 1000 ms 316 | navigator.vibrate(1000); 317 | 318 | // or alternatively 319 | navigator.vibrate([1000]); 320 |321 |
322 | In the following example the pattern will cause the device to vibrate 323 | for 50 ms, be still for 100 ms, and then vibrate for 150 ms: 324 |
325 |326 | navigator.vibrate([50, 100, 150]); 327 |328 |
329 | The following example cancels any existing vibrations: 330 |
331 |332 | // cancel any existing vibrations 333 | navigator.vibrate(0); 334 | 335 | // or alternatively 336 | navigator.vibrate([]); 337 |338 |
344 | The group is deeply indebted to Justin Lebar, Mounir Lamouri, Jonas 345 | Sicking, and the Mozilla WebAPI team for their contributions, and for 346 | providing the WebVibrator prototype as an initial input. Thanks to Anne 347 | van Kesteren for suggestions on how to make the specification reusable 348 | in other contexts, and to Lukasz Olejnik for the privacy 349 | considerations. Finally, thanks to Zhiqiang Zhang for the Simplified 350 | Chinese translation. 351 |
352 |50 | The following editorial changes were made since the 51 | 52 | W3C Candidate Recommendation 09 September 2014 53 | (diff): 54 |
55 |VibratePattern
58 | shorthand was added.
59 | 68 | This document represents the consensus of the group on the scope and 69 | features of the Vibration API. It should be noted that the group is 70 | aware of more advanced use cases that cannot be realized using this 71 | simpler first version. The intent is to address them in a future 72 | revision. 73 |
74 |79 | The API is specifically designed to address use cases that require 80 | simple tactile feedback only. Use cases requiring more fine-grained 81 | control are out of scope for this specification. This API is not meant 82 | to be used as a generic notification mechanism. Such use cases may be 83 | handled using the Notifications API [[NOTIFICATIONS]] 84 | specification. In addition, determining whether vibration is enabled 85 | is out of scope for this specification. 86 |
87 |91 | This specification defines conformance criteria that apply to a single 92 | product: the user agent that implements the 93 | interfaces that it contains. 94 |
95 |96 | Implementations that use ECMAScript to implement the APIs defined in 97 | this specification must implement them in a manner consistent with the 98 | ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], 99 | as this specification uses that specification and terminology. 100 |
101 |106 | The concepts 107 | browsing context and 108 | 109 | spin the event loop are defined in [[!HTML5]]. 110 |
111 |
127 | The vibrate()
128 | method, when invoked, MUST run the algorithm
129 | for processing vibration patterns.
130 |
132 | The rules for processing vibration patterns are as given in 133 | the following algorithm: 134 |
135 |vibrate()
method.
139 |
146 |
147 | hidden
attribute [[!PAGE-VISIBILITY]] is set to true,
148 | then return false and terminate these steps.
149 | 161 | To validate and normalize a vibration pattern given 162 | pattern, run these steps: 163 |
164 |219 | To perform vibration using pattern, run these 220 | steps: 221 |
222 |
266 | When the
267 |
268 | visibilitychange
event [[!PAGE-VISIBILITY]] is dispatched at
269 | the Document
in a browsing context, the
270 | user agent MUST abort the
271 | already running processing vibration patterns algorithm, if any.
272 |
278 | In the following example the device will vibrate for 1000 milliseconds (ms): 279 |
280 | // vibrate for 1000 ms 281 | navigator.vibrate(1000); 282 | 283 | // or alternatively 284 | navigator.vibrate([1000]); 285 |286 |
287 | In the following example the pattern will cause the device to vibrate 288 | for 50 ms, be still for 100 ms, and then vibrate for 150 ms: 289 |
290 |291 | navigator.vibrate([50, 100, 150]); 292 |293 |
294 |
295 | The following example cancels any existing vibrations: 296 |
297 |298 | // cancel any existing vibrations 299 | navigator.vibrate(0); 300 | 301 | // or alternatively 302 | navigator.vibrate([]); 303 |304 |
308 | The group is deeply indebted to Justin Lebar, Mounir Lamouri, Jonas 309 | Sicking, and the Mozilla WebAPI team for their contributions, and for 310 | providing the WebVibrator prototype as an initial input. Thanks to 311 | Anne van Kesteren for suggestions on how to make the specification 312 | reusable in other contexts. 313 |
314 |