From 80e8001cd4875119ea70b756891755e47a803932 Mon Sep 17 00:00:00 2001
From: ATimmermann <anke.timmermann@gv.hamburg.de>
Date: Thu, 17 Nov 2022 09:43:12 +0100
Subject: [PATCH] DPS-1349 set EventListener for twoFingerPan on map div
 instead of the window

---
 CHANGELOG.md                                       |  7 ++++---
 .../store/actions/actionsMapAttributesMapper.js    | 14 ++++++++++----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3774bf5af1..bbcb64633b 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,7 @@
 ### Changed
 - fileImport: If the features of the imported file are removed from MP, the imported file name will be removed from the "Successfully imported" list
 - package.json test:vue: excluded /cosi/node_modules from test paths (now matching masterportal root packages that are not tested)
-- layerSelector: update function calls and bootstrap usage 
+- layerSelector: update function calls and bootstrap usage
 ### Deprecated
 
 ### Removed
@@ -23,10 +23,11 @@
 - Fix some vulnerabilities in dependencies
 - Issue #821: Sorting the table in featureLister tool now works again
 - Issue #845: The buffer analysis tool now shows results correctly again
-- DPS-1355: Fix the position of the unfreeze button which should be over the menu on the touch table view
-- DPS-1355: After a layer is selected from the search results it is now getting added to the layer tree again
+- Fix the position of the unfreeze button which should be over the menu on the touch table view
+- After a layer is selected from the search results it is now getting added to the layer tree again
 - Issue #851: Filter - When the multiLayerSelector attribute is set to false, it no longer prevents the accordions from opening.
 - Issue #853: The quickHelp tool is now configurable for the layer tree
+- Do not show alert message to use 2 Fingers on GFI Window or any other div apart from map if twoFingerPan is configured to true
 ---
 
 ## Unreleased - in development
diff --git a/src/core/maps/store/actions/actionsMapAttributesMapper.js b/src/core/maps/store/actions/actionsMapAttributesMapper.js
index 67c57ebe6d..19fefcd297 100644
--- a/src/core/maps/store/actions/actionsMapAttributesMapper.js
+++ b/src/core/maps/store/actions/actionsMapAttributesMapper.js
@@ -20,8 +20,10 @@ export default {
         dispatch("registerListener", {type: "click", listener: "updateClick", listenerType: "dispatch"});
 
         if (rootState.configJson.Portalconfig.mapView?.twoFingerPan) {
-            window.addEventListener("touchmove", (event) => dispatch("oneFingerDragMessage", event));
-            window.addEventListener("touchend", (event) => dispatch("oneFingerDragMessageEnd", event));
+            const mapDiv = document.getElementById("map");
+
+            mapDiv.addEventListener("touchmove", (event) => dispatch("oneFingerDragMessage", event));
+            mapDiv.addEventListener("touchend", (event) => dispatch("oneFingerDragMessageEnd", event));
         }
 
         dispatch("setViewAttributes", map.getView());
@@ -219,6 +221,7 @@ export default {
      * Removes the touchmove and touchend event listeners added for the two finger pan alert message
      * @param {Object} param.dispatch the dispatch
      * @param {Object} param.commit the commit
+     * @param {Element} mapDiv html element of the map
      * @param {Event} event touchend
      * @returns {void}
      */
@@ -229,7 +232,10 @@ export default {
         if (event.targetTouches?.length === 0) {
             commit("setTwoFingerPanStart", false);
         }
-        window.removeEventListener("touchmove", dispatch("oneFingerDragMessage"));
-        window.removeEventListener("touchend", dispatch("oneFingerDragMessageEnd"));
+
+        const mapDiv = document.getElementById("map");
+
+        mapDiv.removeEventListener("touchmove", dispatch("oneFingerDragMessage"));
+        mapDiv.removeEventListener("touchend", dispatch("oneFingerDragMessageEnd"));
     }
 };
-- 
GitLab