navigator.vibrate fix (sometimes missing depending on browser)
This commit is contained in:
parent
b978b6fa9d
commit
c30e105c6e
1 changed files with 17 additions and 0 deletions
|
|
@ -253,6 +253,22 @@ function installFetchShim() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function installVibrateShim() {
|
||||||
|
if (typeof navigator.vibrate === "function") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some Firefox configurations leave navigator.vibrate undefined (gated by dom.vibrator.enabled).
|
||||||
|
// Obsidian assumes it's always callable, so provide a no-op where it's missing.
|
||||||
|
try {
|
||||||
|
Object.defineProperty(navigator, "vibrate", {
|
||||||
|
configurable: true,
|
||||||
|
writable: true,
|
||||||
|
value: () => true,
|
||||||
|
});
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
function installContextMenuFix() {
|
function installContextMenuFix() {
|
||||||
// hacky fix to prevent browser from showing context menu while allowing obsidian context menu
|
// hacky fix to prevent browser from showing context menu while allowing obsidian context menu
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
|
|
@ -271,5 +287,6 @@ export function installGlobals() {
|
||||||
installFetchShim();
|
installFetchShim();
|
||||||
installWindowClose();
|
installWindowClose();
|
||||||
installWindowOpen();
|
installWindowOpen();
|
||||||
|
installVibrateShim();
|
||||||
installContextMenuFix();
|
installContextMenuFix();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue