From 4690bfd5077d9923e2739083fbae775dc55583dc Mon Sep 17 00:00:00 2001
From: Armand Bahi <armand.bahi@veremes.com>
Date: Fri, 30 Nov 2018 11:35:21 +0100
Subject: [PATCH] =?UTF-8?q?Fix=20synchronisation=20si=20on=20ne=20passe=20?=
 =?UTF-8?q?pas=20la=20souris=20par=20la=20carte=20compar=C3=A9e?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../javascript/app/vmap/map/mapcompare.js       | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/module_vmap/module/javascript/app/vmap/map/mapcompare.js b/src/module_vmap/module/javascript/app/vmap/map/mapcompare.js
index b3304a3c..54e49269 100644
--- a/src/module_vmap/module/javascript/app/vmap/map/mapcompare.js
+++ b/src/module_vmap/module/javascript/app/vmap/map/mapcompare.js
@@ -592,11 +592,11 @@ nsVmap.MapCompare.prototype.mapCompareController.prototype.synchronizeMap = func
     var this_ = this;
 
     // Synchro Échelle
-    this_.map.getTargetElement().addEventListener('mouseleave', function(){
+    $(this_.map.getTargetElement()).on('mouseleave', function(){
         oVmap.getMap().getOLMap().on("moveend", this_.updateCompareScaleMap, this_);
         this_.map.un("moveend", this_.updateScaleMap, this_);
     });
-    this_.map.getTargetElement().addEventListener('mouseenter', function(){
+    $(this_.map.getTargetElement()).on('mouseenter', function(){
       oVmap.getMap().getOLMap().un("moveend", this_.updateCompareScaleMap, this_);
       this_.map.on("moveend", this_.updateScaleMap, this_);
     });
@@ -664,13 +664,20 @@ nsVmap.MapCompare.prototype.mapCompareController.prototype.synchronizeMap = func
 
       this_.targetOverlay_.setPosition(convertCoord);
     });
+
+    // Si la souris n'est pas sur la carte comparée, déclenche un mouseleave
+    if (!$(this_.map.getTargetElement()).is(':hover')) {
+        $(this_.map.getTargetElement()).trigger('mouseleave');
+    }
 };
 
 /**
  * Update the map extent with animation
  * @returns {undefined}
  */
-nsVmap.MapCompare.prototype.mapCompareController.prototype.updateCompareScaleMap = function(e) { console.log('updateCompareScaleMap');
+nsVmap.MapCompare.prototype.mapCompareController.prototype.updateCompareScaleMap = function(e) {
+    oVmap.log('nsVmap.MapCompare.updateCompareScaleMap');
+
     var this_ = this
     this_.updateCenterCompareMap();
     oVmap.getMapCompare().setScale(oVmap.getMap().getScale());
@@ -682,7 +689,9 @@ nsVmap.MapCompare.prototype.mapCompareController.prototype.updateCompareScaleMap
  * Update the map extent with animation
  * @returns {undefined}
  */
-nsVmap.MapCompare.prototype.mapCompareController.prototype.updateScaleMap = function(e) { console.log('updateScaleMap');
+nsVmap.MapCompare.prototype.mapCompareController.prototype.updateScaleMap = function(e) {
+    oVmap.log('nsVmap.MapCompare.updateScaleMap');
+
     var this_ = this
     this_.updateCenterMap();
     oVmap.getMap().setScale(oVmap.getMapCompare().getScale());
-- 
GitLab