Introduce vibrateIfPossible into the utils package. This will check if the browser
has support for vibrating. This fixes a number of bugs for iOS safari & friends.
This commit is contained in:
@@ -828,3 +828,9 @@ const MOBILE_USER_AGENTS = ["iPhone", "iPad", "Android", "BlackBerry", "WebOs"].
|
||||
export function isMobileBrowser(userAgent: string): boolean {
|
||||
return MOBILE_USER_AGENTS.some(a => userAgent.match(a))
|
||||
}
|
||||
|
||||
export function vibrateIfPossible(strength: number | Array<number>) {
|
||||
if (window.navigator.vibrate) {
|
||||
window.navigator.vibrate(strength);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user