FEATURE: Add Tactile feedback on likes

This commit is contained in:
Rafael dos Santos Silva 2020-01-29 14:24:15 -03:00
parent bf50087d72
commit f15264e977
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

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