From b1d4f01ab5cf95932c7a8c254cceb8ce8a3950d2 Mon Sep 17 00:00:00 2001 From: ijlal99 Date: Wed, 22 Jan 2025 18:41:42 +0500 Subject: [PATCH] Fix/XV-574: markerClicked event is not fired on ios safari --- src/plugins/AnnotationsPlugin/Annotation.js | 3 +++ src/plugins/lib/html/MenuEvent.js | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/AnnotationsPlugin/Annotation.js b/src/plugins/AnnotationsPlugin/Annotation.js index 420902be1..9a44b2666 100644 --- a/src/plugins/AnnotationsPlugin/Annotation.js +++ b/src/plugins/AnnotationsPlugin/Annotation.js @@ -173,6 +173,9 @@ class Annotation extends Marker { addContextMenuListener(this._marker, e => { e.preventDefault(); this.plugin.fire("contextmenu", this); + }, e => { + e.preventDefault(); + this.plugin.fire("markerClicked", this); }) this._marker.addEventListener("mouseenter", () => { this.plugin.fire("markerMouseEnter", this); diff --git a/src/plugins/lib/html/MenuEvent.js b/src/plugins/lib/html/MenuEvent.js index 05b419ca1..a6760a8b0 100644 --- a/src/plugins/lib/html/MenuEvent.js +++ b/src/plugins/lib/html/MenuEvent.js @@ -1,6 +1,7 @@ import { os } from "../../../viewer/utils/os.js"; -export function addContextMenuListener(elem, callback) { +//failCallback will be called when the press is not long enough to considered a long press +export function addContextMenuListener(elem, callback, failCallback = () => {}) { if (!elem || !callback) return; let timeout = null; @@ -54,6 +55,7 @@ export function addContextMenuListener(elem, callback) { const touchEndHandler = (event) => { event.preventDefault(); if (timeout) { + failCallback(event); clearTimeout(timeout); timeout = null; }