diff --git a/app/assets/javascripts/discourse/pre-initializers/sniff-capabilities.js.es6 b/app/assets/javascripts/discourse/pre-initializers/sniff-capabilities.js.es6 index 1e111506e8b..c8c35032ce2 100644 --- a/app/assets/javascripts/discourse/pre-initializers/sniff-capabilities.js.es6 +++ b/app/assets/javascripts/discourse/pre-initializers/sniff-capabilities.js.es6 @@ -46,6 +46,8 @@ export default { caps.hasContactPicker = "contacts" in navigator && "ContactsManager" in window; + + caps.canVibrate = "vibrate" in navigator; } // We consider high res a device with 1280 horizontal pixels. High DPI tablets like diff --git a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 index e7d51a1fa76..c833d8edf97 100644 --- a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 @@ -8,6 +8,7 @@ import { Promise } from "rsvp"; import ENV from "discourse-common/config/environment"; const LIKE_ACTION = 2; +const VIBRATE_DURATION = 5; function animateHeart($elem, start, end, complete) { if (ENV.environment === "test") { @@ -651,6 +652,10 @@ export default createWidget("post-menu", { return this.sendWidgetAction("showLogin"); } + if (this.capabilities.canVibrate) { + navigator.vibrate(VIBRATE_DURATION); + } + if (attrs.liked) { return this.sendWidgetAction("toggleLike"); }