Skip to content

Commit

Permalink
fix touch events on iOS 13
Browse files Browse the repository at this point in the history
  • Loading branch information
iantrich committed Nov 18, 2019
1 parent 4e20f48 commit 663e55f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "radial-menu",
"version": "1.4.7",
"version": "1.4.8",
"description": "Lovelace radial-menu",
"keywords": [
"home-assistant",
Expand Down
16 changes: 7 additions & 9 deletions src/action-handler-directive.ts
Expand Up @@ -90,12 +90,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);
Expand Down Expand Up @@ -141,7 +139,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);
Expand All @@ -168,7 +166,7 @@ class ActionHandler extends HTMLElement implements ActionHandler {

customElements.define('action-handler-radial', ActionHandler);

const geActionHandler = (): ActionHandler => {
const getActionHandler = (): ActionHandler => {
const body = document.body;
if (body.querySelector('action-handler-radial')) {
return body.querySelector('action-handler-radial') as ActionHandler;
Expand All @@ -181,7 +179,7 @@ const geActionHandler = (): ActionHandler => {
};

export const actionHandlerBind = (element: ActionHandlerElement, options: ActionHandlerOptions): void => {
const actionhandler: ActionHandler = geActionHandler();
const actionhandler: ActionHandler = getActionHandler();
if (!actionhandler) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/const.ts
@@ -1 +1 @@
export const CARD_VERSION = '1.4.7';
export const CARD_VERSION = '1.4.8';

0 comments on commit 663e55f

Please sign in to comment.