Thu, 04 Jun 2015 14:50:33 +0200
Genesis of lecture sources for Droidcon Berlin 2015 in Postbahnhof.
michael@0 | 1 | <!--- |
michael@0 | 2 | Licensed to the Apache Software Foundation (ASF) under one |
michael@0 | 3 | or more contributor license agreements. See the NOTICE file |
michael@0 | 4 | distributed with this work for additional information |
michael@0 | 5 | regarding copyright ownership. The ASF licenses this file |
michael@0 | 6 | to you under the Apache License, Version 2.0 (the |
michael@0 | 7 | "License"); you may not use this file except in compliance |
michael@0 | 8 | with the License. You may obtain a copy of the License at |
michael@0 | 9 | |
michael@0 | 10 | http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 11 | |
michael@0 | 12 | Unless required by applicable law or agreed to in writing, |
michael@0 | 13 | software distributed under the License is distributed on an |
michael@0 | 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
michael@0 | 15 | KIND, either express or implied. See the License for the |
michael@0 | 16 | specific language governing permissions and limitations |
michael@0 | 17 | under the License. |
michael@0 | 18 | --> |
michael@0 | 19 | |
michael@0 | 20 | # org.apache.cordova.vibration |
michael@0 | 21 | |
michael@0 | 22 | 這個外掛程式將對齊與 W3C 振動規範 HTTP://www.w3.org/TR/vibration/ |
michael@0 | 23 | |
michael@0 | 24 | 這個外掛程式提供了方法振動設備。 |
michael@0 | 25 | |
michael@0 | 26 | ## 安裝 |
michael@0 | 27 | |
michael@0 | 28 | cordova plugin add org.apache.cordova.vibration |
michael@0 | 29 | |
michael@0 | 30 | |
michael@0 | 31 | ## 支援的平臺 |
michael@0 | 32 | |
michael@0 | 33 | navigator.vibrate |
michael@0 | 34 | navigator.notification.vibrate-亞馬遜火 OS-Android-黑莓 10-火狐瀏覽器作業系統 — — iOS-Windows Phone 7 和 8 |
michael@0 | 35 | |
michael@0 | 36 | navigator.notification.vibrateWithPattern, |
michael@0 | 37 | navigator.notification.cancelVibration-安卓系統 |
michael@0 | 38 | |
michael@0 | 39 | ## 震動 (推薦) |
michael@0 | 40 | |
michael@0 | 41 | 此函數具有三個不同的功能,基於參數傳遞給它。 |
michael@0 | 42 | |
michael@0 | 43 | ### 標準振動 |
michael@0 | 44 | |
michael@0 | 45 | 為給定時間振動設備。 |
michael@0 | 46 | |
michael@0 | 47 | navigator.vibrate(time) |
michael@0 | 48 | |
michael@0 | 49 | |
michael@0 | 50 | 或 |
michael@0 | 51 | |
michael@0 | 52 | navigator.vibrate([time]) |
michael@0 | 53 | |
michael@0 | 54 | |
michael@0 | 55 | -**時間**: 毫秒以振動裝置。*(人數)* |
michael@0 | 56 | |
michael@0 | 57 | #### 示例 |
michael@0 | 58 | |
michael@0 | 59 | // Vibrate for 3 seconds |
michael@0 | 60 | navigator.vibrate(3000); |
michael@0 | 61 | |
michael@0 | 62 | // Vibrate for 3 seconds |
michael@0 | 63 | navigator.vibrate([3000]); |
michael@0 | 64 | |
michael@0 | 65 | |
michael@0 | 66 | #### iOS 的怪癖 |
michael@0 | 67 | |
michael@0 | 68 | * **時間**: 忽略指定的時間和震動的一個預先設定的時間。 |
michael@0 | 69 | |
michael@0 | 70 | navigator.vibrate(3000); // 3000 is ignored |
michael@0 | 71 | |
michael@0 | 72 | #### Windows 和黑莓的怪癖 |
michael@0 | 73 | |
michael@0 | 74 | * **時間**: 最長時間是 5000ms (5s) 和最小時間為 1ms |
michael@0 | 75 | |
michael@0 | 76 | navigator.vibrate(8000); // will be truncated to 5000 |
michael@0 | 77 | |
michael@0 | 78 | ### 以一種模式 (安卓系統和僅限 Windows) 振動 |
michael@0 | 79 | |
michael@0 | 80 | 振動具有給定模式的設備 |
michael@0 | 81 | |
michael@0 | 82 | navigator.vibrate(pattern); |
michael@0 | 83 | |
michael@0 | 84 | |
michael@0 | 85 | * **模式**: 序列的持續時間 (以毫秒為單位) 為其打開或關閉振動器。*(數位陣列)* |
michael@0 | 86 | |
michael@0 | 87 | #### 示例 |
michael@0 | 88 | |
michael@0 | 89 | // Vibrate for 1 second |
michael@0 | 90 | // Wait for 1 second |
michael@0 | 91 | // Vibrate for 3 seconds |
michael@0 | 92 | // Wait for 1 second |
michael@0 | 93 | // Vibrate for 5 seconds |
michael@0 | 94 | navigator.vibrate([1000, 1000, 3000, 1000, 5000]); |
michael@0 | 95 | |
michael@0 | 96 | |
michael@0 | 97 | ### 取消振動 (iOS 中不支援) |
michael@0 | 98 | |
michael@0 | 99 | 立即取消任何當前正在運行的振動。 |
michael@0 | 100 | |
michael@0 | 101 | navigator.vibrate(0) |
michael@0 | 102 | |
michael@0 | 103 | |
michael@0 | 104 | 或 |
michael@0 | 105 | |
michael@0 | 106 | navigator.vibrate([]) |
michael@0 | 107 | |
michael@0 | 108 | |
michael@0 | 109 | 或 |
michael@0 | 110 | |
michael@0 | 111 | navigator.vibrate([0]) |
michael@0 | 112 | |
michael@0 | 113 | |
michael@0 | 114 | 在一個為 0 的參數中傳遞,空陣列或陣列的一個元素的值為 0 將取消任何振動。 |
michael@0 | 115 | |
michael@0 | 116 | ## *notification.vibrate (已棄用) |
michael@0 | 117 | |
michael@0 | 118 | 為給定時間振動設備。 |
michael@0 | 119 | |
michael@0 | 120 | navigator.notification.vibrate(time) |
michael@0 | 121 | |
michael@0 | 122 | |
michael@0 | 123 | * **時間**: 毫秒以振動裝置。*(人數)* |
michael@0 | 124 | |
michael@0 | 125 | ### 示例 |
michael@0 | 126 | |
michael@0 | 127 | // Vibrate for 2.5 seconds |
michael@0 | 128 | navigator.notification.vibrate(2500); |
michael@0 | 129 | |
michael@0 | 130 | |
michael@0 | 131 | ### iOS 的怪癖 |
michael@0 | 132 | |
michael@0 | 133 | * **時間**: 忽略指定的時間和震動的一個預先設定的時間。 |
michael@0 | 134 | |
michael@0 | 135 | navigator.notification.vibrate(); |
michael@0 | 136 | navigator.notification.vibrate(2500); // 2500 is ignored |
michael@0 | 137 | |
michael@0 | 138 | |
michael@0 | 139 | ## *notification.vibrateWithPattern (已棄用) |
michael@0 | 140 | |
michael@0 | 141 | 振動具有給定模式的設備。 |
michael@0 | 142 | |
michael@0 | 143 | navigator.notification.vibrateWithPattern(pattern, repeat) |
michael@0 | 144 | |
michael@0 | 145 | |
michael@0 | 146 | * **模式**: 序列的持續時間 (以毫秒為單位) 為其打開或關閉振動器。*(數位陣列)* |
michael@0 | 147 | * **重複**: 在其開始重複 (會重複,直到被取消),或-1 為不重複 (預設值) 模式陣列中的可選索引。*(人數)* |
michael@0 | 148 | |
michael@0 | 149 | ### 示例 |
michael@0 | 150 | |
michael@0 | 151 | // Immediately start vibrating |
michael@0 | 152 | // vibrate for 100ms, |
michael@0 | 153 | // wait for 100ms, |
michael@0 | 154 | // vibrate for 200ms, |
michael@0 | 155 | // wait for 100ms, |
michael@0 | 156 | // vibrate for 400ms, |
michael@0 | 157 | // wait for 100ms, |
michael@0 | 158 | // vibrate for 800ms, |
michael@0 | 159 | // (do not repeat) |
michael@0 | 160 | navigator.notification.vibrateWithPattern([0, 100, 100, 200, 100, 400, 100, 800]); |
michael@0 | 161 | |
michael@0 | 162 | |
michael@0 | 163 | ## *notification.cancelVibration (已棄用) |
michael@0 | 164 | |
michael@0 | 165 | 立即取消任何當前正在運行的振動。 |
michael@0 | 166 | |
michael@0 | 167 | navigator.notification.cancelVibration() |
michael@0 | 168 | |
michael@0 | 169 | |
michael@0 | 170 | * 請注意--對齊方式與 w3c 規範,因出演的方法將被淘汰 |