From 3d3ebdff15a9ad3e9fef665eb551d13661d89b7d Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Tue, 13 Jun 2023 22:51:53 +0000 Subject: [PATCH] added haptics core --- .../app/src/cores/haptics/haptics.core.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 packages/app/src/cores/haptics/haptics.core.js diff --git a/packages/app/src/cores/haptics/haptics.core.js b/packages/app/src/cores/haptics/haptics.core.js new file mode 100644 index 00000000..dfb34ec4 --- /dev/null +++ b/packages/app/src/cores/haptics/haptics.core.js @@ -0,0 +1,28 @@ +import Core from "evite/src/core" + +export default class HapticsCore extends Core { + static refName = "haptics" + static namespace = "haptics" + static dependencies = [ + "settings" + ] + + static get isGlobalDisabled() { + return app.cores.settings.get("haptic_feedback") + } + + public = { + isGlobalDisabled: HapticsCore.isGlobalDisabled, + vibration: this.vibration.bind(this), + } + + vibration(...args) { + const disabled = this.isGlobalDisabled + + if (disabled) { + return false + } + + return navigator.vibrate(...args) + } +} \ No newline at end of file