[Libreoffice-commits] online.git: loleaflet/src

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 14 14:26:28 UTC 2020


 loleaflet/src/control/Control.Scroll.js |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 0ca8e3b63946862dad47163e448fca84741421d2
Author:     Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Fri Feb 14 18:11:37 2020 +0530
Commit:     Dennis Francis <dennis.francis at collabora.com>
CommitDate: Fri Feb 14 15:26:07 2020 +0100

    Lets have Hammer pan listeners on scroll-container...
    
    and delegate the pan events to L.Map.TouchGesture's pan handlers.
    
    This solves the problem that if one starts to pan the sheet from
    near the right edge (where the vertical scroll div exists), no
    panning takes place. This is because the vertical scroll div
    is managed by custom jquery plugin and has a high z-index and
    mapPane is not an ancestor of it, so mapPane will not get the
    touch events even with event bubble-up. But its ancestor div
    'scroll-container' still gets touch/move events and has the same
    size and location as that of mapPane. So we just need to register
    Hammer for pan events for scroll-container and delegate these events
    to the original pan handlers of mapPane without any change to the
    event coordinates.
    
    The scroll widget and the drag-rail still function as usual as they
    are succesors of scroll-container and they get all the events they
    need to handle.
    
    Change-Id: Ie4ffe07a0889c5710b2c6d09e4eb90f0671b5ad0
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88712
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
index 91da67f41..8988df9ea 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -3,7 +3,7 @@
  * L.Control.Scroll handles scrollbars
  */
 
-/* global $ clearTimeout setTimeout */
+/* global $ clearTimeout setTimeout Hammer */
 L.Control.Scroll = L.Control.extend({
 
 	onAdd: function (map) {
@@ -62,6 +62,22 @@ L.Control.Scroll = L.Control.extend({
 				alwaysTriggerOffsets: false
 			}
 		});
+
+		if (!this._hammer && map.touchGesture) {
+			this._hammer = new Hammer(this._scrollContainer);
+			this._hammer.get('pan').set({
+				direction: Hammer.DIRECTION_ALL
+			});
+
+			if (L.Browser.touch) {
+				L.DomEvent.on(this._scrollContainer, 'touchmove', L.DomEvent.preventDefault);
+			}
+
+			var mapTouchGesture = map.touchGesture;
+			this._hammer.on('panstart', L.bind(mapTouchGesture._onPanStart, mapTouchGesture));
+			this._hammer.on('pan', L.bind(mapTouchGesture._onPan, mapTouchGesture));
+			this._hammer.on('panend', L.bind(mapTouchGesture._onPanEnd, mapTouchGesture));
+		}
 	},
 
 	_onCalcScroll: function (e) {


More information about the Libreoffice-commits mailing list