mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 21:37:21 +00:00
Forward haptic events to external apps (#3116)
* Forward haptic events to external apps * Fix types
This commit is contained in:
parent
d05b1ef9cc
commit
d79bf5e07e
@ -8,3 +8,8 @@ export const externalForwardConnectionEvents = (bus: ExternalMessaging) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const externalForwardHaptics = (bus: ExternalMessaging) =>
|
||||||
|
document.addEventListener("haptic", (ev) =>
|
||||||
|
bus.fireMessage({ type: "haptic", payload: { hapticType: ev.detail } })
|
||||||
|
);
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { externalForwardConnectionEvents } from "./external_events_forwarder";
|
import {
|
||||||
|
externalForwardConnectionEvents,
|
||||||
|
externalForwardHaptics,
|
||||||
|
} from "./external_events_forwarder";
|
||||||
|
|
||||||
const CALLBACK_EXTERNAL_BUS = "externalBus";
|
const CALLBACK_EXTERNAL_BUS = "externalBus";
|
||||||
|
|
||||||
@ -41,6 +44,7 @@ export class ExternalMessaging {
|
|||||||
|
|
||||||
public attach() {
|
public attach() {
|
||||||
externalForwardConnectionEvents(this);
|
externalForwardConnectionEvents(this);
|
||||||
|
externalForwardHaptics(this);
|
||||||
window[CALLBACK_EXTERNAL_BUS] = (msg) => this.receiveMessage(msg);
|
window[CALLBACK_EXTERNAL_BUS] = (msg) => this.receiveMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Utility function that enables haptic feedback
|
* Utility function that enables haptic feedback
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent, HASSDomEvent } from "../common/dom/fire_event";
|
||||||
|
|
||||||
// Allowed types are from iOS HIG.
|
// Allowed types are from iOS HIG.
|
||||||
// https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/feedback/#haptics
|
// https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/feedback/#haptics
|
||||||
@ -21,6 +21,10 @@ declare global {
|
|||||||
interface HASSDomEvents {
|
interface HASSDomEvents {
|
||||||
haptic: HapticType;
|
haptic: HapticType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface GlobalEventHandlersEventMap {
|
||||||
|
haptic: HASSDomEvent<HapticType>;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const forwardHaptic = (el: HTMLElement, hapticType: HapticType) => {
|
export const forwardHaptic = (el: HTMLElement, hapticType: HapticType) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user