summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-11-22 14:15:38 +0200
committerTor Lillqvist <tml@collabora.com>2018-11-22 14:58:56 +0200
commite27ae38bebf4b57aa7563357a188e33d0e1e0be8 (patch)
treec4623d25354f5c64060d4d49d4aaac7b5ed59e57
parent9606c29d64bc7526a4a65848613b8ee288936ed2 (diff)
Fix jumping after touch zooming also for mobile clients of normal Online
Don't check window.ThisIsAMobileApp but instead use a much more convoluted test to catch only the cases where we do want the document to be scrolled, and ignore the case that causes the irritating jumping. In _onUpdateCursor() in TileLayer.js, we know that the scroll parameter is not undefined when and only when _onUpdateCursor() is called from _onInvalidateCursorMsg(). We pass that information down to the onUpdate callback handler passed to the _tweenTo() function in the _scrollTo() function in jquery.mCustomScrollbar.js where it shows up as property of the options object. In that location we also make use of the incidental fact that options.timeout==1 only when that code is called from mouse-wheel scrolling. Quite possibly all this could be done much cleaner. Change-Id: Iefa257bceb54137f25534ccb6786c1d2e315931c
-rw-r--r--loleaflet/js/jquery.mCustomScrollbar.js11
-rw-r--r--loleaflet/src/control/Control.Scroll.js3
-rw-r--r--loleaflet/src/layer/tile/TileLayer.js2
3 files changed, 12 insertions, 4 deletions
diff --git a/loleaflet/js/jquery.mCustomScrollbar.js b/loleaflet/js/jquery.mCustomScrollbar.js
index 0a933b063..a0d2d325e 100644
--- a/loleaflet/js/jquery.mCustomScrollbar.js
+++ b/loleaflet/js/jquery.mCustomScrollbar.js
@@ -1,4 +1,4 @@
-/* -*- js-indent-level: 8; indent-tabs-mode: t -*- */
+/* -*- js-indent-level: 8; indent-tabs-mode: t; fill-column: 120 -*- */
/*
== malihu jquery custom scrollbar plugin ==
Version: 3.1.3
@@ -2120,7 +2120,14 @@ and dependencies (minified).
}
},onUpdate:function(){
if(options.callbacks && options.onUpdate){
- if (!window.ThisIsAMobileApp || options.drag) {
+ // This condition is intended to filter out the case when this gets
+ // invoked from a touch pinch gesture, but let through the cases of
+ // scrolling with mouse-wheel or touchpad, dragging the scrollbar
+ // slider, or implicit scrolling because of editing in a previously
+ // hidden part of the document (for instance when pressing enter on the
+ // last visible line). The options.timeout==1 is a silly way to detect
+ // the mouse-wheel scrolling.
+ if(options.drag || options.timeout===1 || options.calledFromInvalidateCursorMsg==true){
/* callbacks: whileScrolling */
if(_cb("whileScrolling")){_mcs(); o.callbacks.whileScrolling.call(el[0]);}
}
diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
index 3f49ec4a0..829ce18ab 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -155,7 +155,7 @@ L.Control.Scroll = L.Control.extend({
_onScrollTo: function (e) {
// triggered by the document (e.g. search result out of the viewing area)
- $('.scroll-container').mCustomScrollbar('scrollTo', [e.y, e.x]);
+ $('.scroll-container').mCustomScrollbar('scrollTo', [e.y, e.x], {calledFromInvalidateCursorMsg: e.calledFromInvalidateCursorMsg});
},
_onScrollBy: function (e) {
@@ -169,6 +169,7 @@ L.Control.Scroll = L.Control.extend({
if (e.x < 0) {
x = '-=' + Math.abs(e.x);
}
+ // Note: timeout===1 is checked in my extremely ugly hack in jquery.mCustomScrollbar.js.
$('.scroll-container').mCustomScrollbar('scrollTo', [y, x], { timeout: 1 });
},
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 6147276ff..dab81ba49 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1608,7 +1608,7 @@ L.TileLayer = L.GridLayer.extend({
if (!(this._selectionHandles.start && this._selectionHandles.start.isDragged) &&
!(this._selectionHandles.end && this._selectionHandles.end.isDragged) &&
!(docLayer._followEditor || docLayer._followUser)) {
- this._map.fire('scrollto', {x: center.x, y: center.y});
+ this._map.fire('scrollto', {x: center.x, y: center.y, calledFromInvalidateCursorMsg: scroll !== undefined});
}
}