mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-25 07:34:45 +00:00
[add] Vibration API
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
const vibrate = (pattern) => {
|
||||
if ('vibrate' in window.navigator) {
|
||||
if (typeof pattern === 'number' || Array.isArray(pattern)) {
|
||||
window.navigator.vibrate(pattern)
|
||||
} else {
|
||||
throw new Error('Vibration pattern should be a number or array')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Vibration = {
|
||||
cancel() {
|
||||
vibrate(0)
|
||||
},
|
||||
vibrate(pattern) {
|
||||
vibrate(pattern)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Vibration
|
||||
@@ -18,6 +18,7 @@ import PixelRatio from './apis/PixelRatio'
|
||||
import Platform from './apis/Platform'
|
||||
import StyleSheet from './apis/StyleSheet'
|
||||
import UIManager from './apis/UIManager'
|
||||
import Vibration from './apis/Vibration'
|
||||
|
||||
// components
|
||||
import ActivityIndicator from './components/ActivityIndicator'
|
||||
@@ -65,6 +66,7 @@ const ReactNative = {
|
||||
Platform,
|
||||
StyleSheet,
|
||||
UIManager,
|
||||
Vibration,
|
||||
|
||||
// components
|
||||
ActivityIndicator,
|
||||
|
||||
Reference in New Issue
Block a user