|
1 <!--- |
|
2 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 |
|
20 # org.apache.cordova.vibration |
|
21 |
|
22 這個外掛程式將對齊與 W3C 振動規範 HTTP://www.w3.org/TR/vibration/ |
|
23 |
|
24 這個外掛程式提供了方法振動設備。 |
|
25 |
|
26 ## 安裝 |
|
27 |
|
28 cordova plugin add org.apache.cordova.vibration |
|
29 |
|
30 |
|
31 ## 支援的平臺 |
|
32 |
|
33 navigator.vibrate |
|
34 navigator.notification.vibrate-亞馬遜火 OS-Android-黑莓 10-火狐瀏覽器作業系統 — — iOS-Windows Phone 7 和 8 |
|
35 |
|
36 navigator.notification.vibrateWithPattern, |
|
37 navigator.notification.cancelVibration-安卓系統 |
|
38 |
|
39 ## 震動 (推薦) |
|
40 |
|
41 此函數具有三個不同的功能,基於參數傳遞給它。 |
|
42 |
|
43 ### 標準振動 |
|
44 |
|
45 為給定時間振動設備。 |
|
46 |
|
47 navigator.vibrate(time) |
|
48 |
|
49 |
|
50 或 |
|
51 |
|
52 navigator.vibrate([time]) |
|
53 |
|
54 |
|
55 -**時間**: 毫秒以振動裝置。*(人數)* |
|
56 |
|
57 #### 示例 |
|
58 |
|
59 // Vibrate for 3 seconds |
|
60 navigator.vibrate(3000); |
|
61 |
|
62 // Vibrate for 3 seconds |
|
63 navigator.vibrate([3000]); |
|
64 |
|
65 |
|
66 #### iOS 的怪癖 |
|
67 |
|
68 * **時間**: 忽略指定的時間和震動的一個預先設定的時間。 |
|
69 |
|
70 navigator.vibrate(3000); // 3000 is ignored |
|
71 |
|
72 #### Windows 和黑莓的怪癖 |
|
73 |
|
74 * **時間**: 最長時間是 5000ms (5s) 和最小時間為 1ms |
|
75 |
|
76 navigator.vibrate(8000); // will be truncated to 5000 |
|
77 |
|
78 ### 以一種模式 (安卓系統和僅限 Windows) 振動 |
|
79 |
|
80 振動具有給定模式的設備 |
|
81 |
|
82 navigator.vibrate(pattern); |
|
83 |
|
84 |
|
85 * **模式**: 序列的持續時間 (以毫秒為單位) 為其打開或關閉振動器。*(數位陣列)* |
|
86 |
|
87 #### 示例 |
|
88 |
|
89 // Vibrate for 1 second |
|
90 // Wait for 1 second |
|
91 // Vibrate for 3 seconds |
|
92 // Wait for 1 second |
|
93 // Vibrate for 5 seconds |
|
94 navigator.vibrate([1000, 1000, 3000, 1000, 5000]); |
|
95 |
|
96 |
|
97 ### 取消振動 (iOS 中不支援) |
|
98 |
|
99 立即取消任何當前正在運行的振動。 |
|
100 |
|
101 navigator.vibrate(0) |
|
102 |
|
103 |
|
104 或 |
|
105 |
|
106 navigator.vibrate([]) |
|
107 |
|
108 |
|
109 或 |
|
110 |
|
111 navigator.vibrate([0]) |
|
112 |
|
113 |
|
114 在一個為 0 的參數中傳遞,空陣列或陣列的一個元素的值為 0 將取消任何振動。 |
|
115 |
|
116 ## *notification.vibrate (已棄用) |
|
117 |
|
118 為給定時間振動設備。 |
|
119 |
|
120 navigator.notification.vibrate(time) |
|
121 |
|
122 |
|
123 * **時間**: 毫秒以振動裝置。*(人數)* |
|
124 |
|
125 ### 示例 |
|
126 |
|
127 // Vibrate for 2.5 seconds |
|
128 navigator.notification.vibrate(2500); |
|
129 |
|
130 |
|
131 ### iOS 的怪癖 |
|
132 |
|
133 * **時間**: 忽略指定的時間和震動的一個預先設定的時間。 |
|
134 |
|
135 navigator.notification.vibrate(); |
|
136 navigator.notification.vibrate(2500); // 2500 is ignored |
|
137 |
|
138 |
|
139 ## *notification.vibrateWithPattern (已棄用) |
|
140 |
|
141 振動具有給定模式的設備。 |
|
142 |
|
143 navigator.notification.vibrateWithPattern(pattern, repeat) |
|
144 |
|
145 |
|
146 * **模式**: 序列的持續時間 (以毫秒為單位) 為其打開或關閉振動器。*(數位陣列)* |
|
147 * **重複**: 在其開始重複 (會重複,直到被取消),或-1 為不重複 (預設值) 模式陣列中的可選索引。*(人數)* |
|
148 |
|
149 ### 示例 |
|
150 |
|
151 // Immediately start vibrating |
|
152 // vibrate for 100ms, |
|
153 // wait for 100ms, |
|
154 // vibrate for 200ms, |
|
155 // wait for 100ms, |
|
156 // vibrate for 400ms, |
|
157 // wait for 100ms, |
|
158 // vibrate for 800ms, |
|
159 // (do not repeat) |
|
160 navigator.notification.vibrateWithPattern([0, 100, 100, 200, 100, 400, 100, 800]); |
|
161 |
|
162 |
|
163 ## *notification.cancelVibration (已棄用) |
|
164 |
|
165 立即取消任何當前正在運行的振動。 |
|
166 |
|
167 navigator.notification.cancelVibration() |
|
168 |
|
169 |
|
170 * 請注意--對齊方式與 w3c 規範,因出演的方法將被淘汰 |