[Libreoffice-commits] online.git: loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Nov 14 12:20:45 UTC 2018
loleaflet/src/map/Map.js | 9 +++++++--
loleaflet/src/map/handler/Map.Tap.js | 17 ++++++++++++++++-
2 files changed, 23 insertions(+), 3 deletions(-)
New commits:
commit 0340f7be9670104587d6506bcebe1363f3b76c27
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Oct 18 16:50:12 2018 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Nov 14 14:19:35 2018 +0200
Make tapping once (and no other touch gestures) pop up the on-screen keyboard
This fixes both the case of a normal Online instance being accessed
from a mobile device (at least Safari on an iPad), and the iOS app
being developed. The same problems were seen on both. Which isn't
surprising, as as it's the same Webkit software running the same
JavaScript on the same HTML page.
I hope this change does not have some unintended annoying other
consequence.
There is a FIXME: Is there some saner place to store this
_wasSingleTap flag than in this._map._container? It needs to be
readily available over in _handleDOMEvent in Map.js.
Another quickly apparent FIXME is that if the on-screen keyboard
covers the place where you tapped, the document is not scrolled so
that the insertion place would stay in view. But at least this is a
step forward, I hope.
Change-Id: I7ada39f1adbb9a1ac560493d926530968aa44133
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 7ed70c2c7..136f22bd1 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -1068,8 +1068,13 @@ L.Map = L.Evented.extend({
// For touch devices, to pop-up the keyboard, it is required to call
// .focus() method on hidden input within actual 'click' event here
- // Calling from some other place with no real 'click' event doesn't work
- if (type === 'click') {
+ // Calling from some other place with no real 'click' event doesn't work.
+
+ // (tml: For me, for this to work with a mobile device, we need to
+ // accept 'mouseup', too, and check the _wasSingleTap flag set over in Map.Tap.js.)
+ if (type === 'click' || (type === 'mouseup' &&
+ typeof this._container._wasSingleTap !== 'undefined' &&
+ this._container._wasSingleTap)) {
if (this._permission === 'edit') {
this.focus();
}
diff --git a/loleaflet/src/map/handler/Map.Tap.js b/loleaflet/src/map/handler/Map.Tap.js
index 02730a7e2..7772beb90 100644
--- a/loleaflet/src/map/handler/Map.Tap.js
+++ b/loleaflet/src/map/handler/Map.Tap.js
@@ -1,4 +1,4 @@
-/* -*- js-indent-level: 8 -*- */
+/* -*- js-indent-level: 8; fill-column: 100 -*- */
/*
* L.Map.Tap is used to enable mobile hacks like quick taps and long hold.
*/
@@ -20,6 +20,19 @@ L.Map.Tap = L.Handler.extend({
_onDown: function (e) {
if (!e.touches) { return; }
+ // console.log('=========> _onDown, e.touches.length=' + e.touches.length);
+
+ // The start of a two-finger gesture comes in as first _onDown with e.touches.length
+ // == 1, then _onDown with e.touches.length == 2.
+
+ // The _wasSingleTap flag is supposed to mean "we got a single-finger quick tap with
+ // no movement".
+
+ // FIXME: Is there some saner place to store this _wasSingleTap flag than in
+ // this._map._container? It needs to be readily available over in _handleDOMEvent in
+ // Map.js.
+ this._map._container._wasSingleTap = (e.touches.length === 1);
+
L.DomEvent.preventDefault(e);
// don't simulate click or track longpress if more than 1 touch
@@ -49,6 +62,7 @@ L.Map.Tap = L.Handler.extend({
},
_onUp: function (e) {
+ // console.log('=========> _onUp, e.touches.length=' + e.touches.length + ', e.changedTouches.length=' + e.changedTouches.length);
clearTimeout(this._holdTimeout);
L.DomEvent.off(document, {
@@ -74,6 +88,7 @@ L.Map.Tap = L.Handler.extend({
var newPos = new L.Point(first.clientX, first.clientY);
if (newPos.distanceTo(this._startPos) > this._map.options.tapTolerance) {
this._newPos = newPos;
+ this._map._container._wasSingleTap = false;
this._simulateEvent('mousemove', first);
}
},
More information about the Libreoffice-commits
mailing list