PageRenderTime 25ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/cordova-plugin-vibration/doc/zh/README.md

https://gitlab.com/gagandeep/helloworld
Markdown | 190 lines | 108 code | 82 blank | 0 comment | 0 complexity | 032e6152744cba93815ee3b14c660a63 MD5 | raw file
  1. <!--
  2. # license: Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing,
  13. # software distributed under the License is distributed on an
  14. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. # KIND, either express or implied. See the License for the
  16. # specific language governing permissions and limitations
  17. # under the License.
  18. -->
  19. # cordova-plugin-vibration
  20. [![Build Status](https://travis-ci.org/apache/cordova-plugin-vibration.svg)](https://travis-ci.org/apache/cordova-plugin-vibration)
  21. 這個外掛程式將對齊與 W3C 振動規範 HTTP://www.w3.org/TR/vibration/
  22. 這個外掛程式提供了方法振動設備
  23. 這個外掛程式定義全域物件包括 `navigator.vibrate`.
  24. 雖然在全球範圍內他們不可用直到 `deviceready` 事件之後
  25. document.addEventListener("deviceready", onDeviceReady, false);
  26. function onDeviceReady() {
  27. console.log(navigator.vibrate);
  28. }
  29. ## 安裝
  30. cordova plugin add cordova-plugin-vibration
  31. ## 支援的平臺
  32. navigator.vibrate,
  33. navigator.notification.vibrate - Amazon Fire OS - Android - BlackBerry 10 - Firefox OS - iOS - Windows Phone 7 and 8 - Windows (Windows Phone 8.1 devices only)
  34. navigator.notification.vibrateWithPattern
  35. navigator.notification.cancelVibration - Android - Windows Phone 8 - Windows (Windows Phone 8.1 devices only)
  36. ## 震動 (推薦)
  37. 此函數具有三個不同的功能基於傳遞給它的參數
  38. ### 標準振動
  39. 為給定時間振動設備
  40. navigator.vibrate(time)
  41. navigator.vibrate([time])
  42. -**time** 毫秒振動裝置**
  43. #### 示例
  44. // Vibrate for 3 seconds
  45. navigator.vibrate(3000);
  46. // Vibrate for 3 seconds
  47. navigator.vibrate([3000]);
  48. #### iOS 的怪癖
  49. * **time** 忽略指定的時間和震動的一個預先設定的時間
  50. navigator.vibrate(3000); // 3000 is ignored
  51. #### Windows 和黑莓的怪癖
  52. * **time** 最長時間是 5000ms (5s) 和最小時間為 1ms
  53. navigator.vibrate(8000); // will be truncated to 5000
  54. ### 以一種模式 安卓系統和僅限 Windows 振動
  55. 振動具有給定模式的設備
  56. navigator.vibrate(pattern);
  57. * **pattern** 序列的持續時間 以毫秒為單位 為其打開或關閉振動器*數位陣列*
  58. #### 示例
  59. // Vibrate for 1 second
  60. // Wait for 1 second
  61. // Vibrate for 3 seconds
  62. // Wait for 1 second
  63. // Vibrate for 5 seconds
  64. navigator.vibrate([1000, 1000, 3000, 1000, 5000]);
  65. #### Windows Phone 8 怪癖
  66. * vibrate(pattern) 瀑布回來上振動與預設持續時間
  67. #### Windows 的怪癖
  68. * vibrate(pattern) 瀑布回來上振動與預設持續時間
  69. ### 取消振動 iOS 中不支援
  70. 立即取消任何當前正在運行的振動
  71. navigator.vibrate(0)
  72. navigator.vibrate([])
  73. navigator.vibrate([0])
  74. 在一個為 0 的參數中傳遞空陣列或陣列的一個元素的值為 0 將取消任何振動
  75. ## *notification.vibrate (已棄用)
  76. 為給定時間振動設備
  77. navigator.notification.vibrate(time)
  78. * **time** 毫秒振動裝置**
  79. ### 示例
  80. // Vibrate for 2.5 seconds
  81. navigator.notification.vibrate(2500);
  82. ### iOS 的怪癖
  83. * **time** 忽略指定的時間和震動的一個預先設定的時間
  84. navigator.notification.vibrate();
  85. navigator.notification.vibrate(2500); // 2500 is ignored
  86. ## *notification.vibrateWithPattern (已棄用)
  87. 振動具有給定模式的設備
  88. navigator.notification.vibrateWithPattern(pattern, repeat)
  89. * **pattern** 序列的持續時間 以毫秒為單位 為其打開或關閉振動器*數位陣列*
  90. * **repeat** 在從中開始重複 會重複直到取消)-1 預設值 沒有重複模式陣列中的可選索引**
  91. ### 示例
  92. // Immediately start vibrating
  93. // vibrate for 100ms,
  94. // wait for 100ms,
  95. // vibrate for 200ms,
  96. // wait for 100ms,
  97. // vibrate for 400ms,
  98. // wait for 100ms,
  99. // vibrate for 800ms,
  100. // (do not repeat)
  101. navigator.notification.vibrateWithPattern([0, 100, 100, 200, 100, 400, 100, 800]);
  102. ## *notification.cancelVibration (已棄用)
  103. 立即取消任何當前正在運行的振動
  104. navigator.notification.cancelVibration()
  105. * 請注意--由於符合 w3c 規範出演的方法將被淘汰