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:
Haze Booth
2023-08-24 12:02:22 -04:00
parent 6f02912d2e
commit 63d51e9119
12 changed files with 34 additions and 24 deletions

View File

@@ -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);
}
}