mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 01:06:35 +00:00
Fix actions not working on touch devices (#4231)
This commit is contained in:
parent
09e7638c89
commit
6ecc60423f
@ -111,12 +111,10 @@ class ActionHandler extends HTMLElement implements ActionHandler {
|
||||
y = (ev as MouseEvent).pageY;
|
||||
}
|
||||
|
||||
if (options.hasHold) {
|
||||
this.timer = window.setTimeout(() => {
|
||||
this.startAnimation(x, y);
|
||||
this.held = true;
|
||||
}, this.holdTime);
|
||||
}
|
||||
this.timer = window.setTimeout(() => {
|
||||
this.startAnimation(x, y);
|
||||
this.held = true;
|
||||
}, this.holdTime);
|
||||
|
||||
this.cooldownStart = true;
|
||||
window.setTimeout(() => (this.cooldownStart = false), 100);
|
||||
@ -166,7 +164,7 @@ class ActionHandler extends HTMLElement implements ActionHandler {
|
||||
// That might be a bug, but until it's fixed, this should make action-handler work.
|
||||
// If it's not a bug that is fixed, this might need updating with the next iOS version.
|
||||
// Note that all events (both touch and mouse) must be listened for in order to work on computers with both mouse and touchscreen.
|
||||
const isIOS13 = window.navigator.userAgent.match(/iPhone OS 13_/);
|
||||
const isIOS13 = /iPhone OS 13_/.test(window.navigator.userAgent);
|
||||
if (!isIOS13) {
|
||||
element.addEventListener("mousedown", clickStart, { passive: true });
|
||||
element.addEventListener("click", clickEnd);
|
||||
@ -193,7 +191,7 @@ class ActionHandler extends HTMLElement implements ActionHandler {
|
||||
|
||||
customElements.define("action-handler", ActionHandler);
|
||||
|
||||
const geActionHandler = (): ActionHandler => {
|
||||
const getActionHandler = (): ActionHandler => {
|
||||
const body = document.body;
|
||||
if (body.querySelector("action-handler")) {
|
||||
return body.querySelector("action-handler") as ActionHandler;
|
||||
@ -209,7 +207,7 @@ export const actionHandlerBind = (
|
||||
element: ActionHandlerElement,
|
||||
options: ActionHandlerOptions
|
||||
) => {
|
||||
const actionhandler: ActionHandler = geActionHandler();
|
||||
const actionhandler: ActionHandler = getActionHandler();
|
||||
if (!actionhandler) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user