mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
navigator.vibrate fix (sometimes missing depending on browser)
This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user