From c2c1fcdf502e7d9b4752b63b22347cc5af4c8ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 25 Jan 2020 20:37:24 +0100 Subject: [PATCH] maps: use Leaflet.GestureHandling to avoid zooming on map during scroll (#39058) --- debian/control | 1 + setup.py | 1 + wcs/qommon/http_response.py | 2 ++ wcs/qommon/static/js/qommon.map.js | 2 ++ wcs/root.py | 2 +- 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index f40641913..0006e117f 100644 --- a/debian/control +++ b/debian/control @@ -23,6 +23,7 @@ Depends: ${misc:Depends}, ${python3:Depends}, python3-requests, python3-vobject, python3-xstatic-leaflet, + python3-xstatic-leaflet-gesturehandling, uwsgi, uwsgi-plugin-python3 Recommends: python3-dns, diff --git a/setup.py b/setup.py index c806b5147..529627de1 100644 --- a/setup.py +++ b/setup.py @@ -123,6 +123,7 @@ setup( 'django-ckeditor<=4.5.3', 'django-ratelimit<3', 'XStatic-Leaflet', + 'XStatic-Leaflet-GestureHandling', 'pyproj', ], package_dir = { 'wcs': 'wcs' }, diff --git a/wcs/qommon/http_response.py b/wcs/qommon/http_response.py index 85934c761..85a7af594 100644 --- a/wcs/qommon/http_response.py +++ b/wcs/qommon/http_response.py @@ -72,7 +72,9 @@ class HTTPResponse(quixote.http_response.HTTPResponse): if script_name == 'qommon.map.js': self.add_javascript(['jquery.js']) self.add_javascript(['../xstatic/leaflet.js']) + self.add_javascript(['../xstatic/leaflet-gesture-handling.min.js']) self.add_css_include('../xstatic/leaflet.css') + self.add_css_include('../xstatic/leaflet-gesture-handling.min.css') self.add_javascript(['leaflet-gps.js']) self.add_javascript(['../../i18n.js']) if script_name == 'qommon.wysiwyg.js': diff --git a/wcs/qommon/static/js/qommon.map.js b/wcs/qommon/static/js/qommon.map.js index 929450344..595e239df 100644 --- a/wcs/qommon/static/js/qommon.map.js +++ b/wcs/qommon/static/js/qommon.map.js @@ -28,6 +28,8 @@ $(window).on('load', function() { map_options.scrollWheelZoom = 'center'; map_options.doubleClickZoom = 'center'; map_options.maxBounds = null; + } else { + map_options.gestureHandling = true; } var map = L.map($(this).attr('id'), map_options); var map_controls_position = $('body').data('map-controls-position') || 'topleft'; diff --git a/wcs/root.py b/wcs/root.py index cdb329741..85283f8a5 100644 --- a/wcs/root.py +++ b/wcs/root.py @@ -195,7 +195,7 @@ class StaticsDirectory(Directory): '': ['web', 'qommon', 'django:gadjo', 'django:ckeditor'], 'xstatic': ['xstatic:jquery', 'xstatic:jquery_ui', 'xstatic:font_awesome', 'xstatic:opensans', - 'xstatic:leaflet',], + 'xstatic:leaflet', 'xstatic:leaflet_gesturehandling'], } @classmethod