diff options
author | Henry Castro <hcastro@collabora.com> | 2020-08-14 09:43:08 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-09-21 11:21:50 +0200 |
commit | 283e3951ce69d638a7cae870aecf362280b4acc2 (patch) | |
tree | 61c272d0b07cb5fd043795b48406b6ee9ee3569f /loleaflet | |
parent | 40ade379183307b650566d933d36bf710d87951e (diff) |
mobile: pre-condition if they are numbers
The hammer library sometimes or random when
consecutively pinch events, the center and scale
has infinity values
Change-Id: Ide6605bcbc0c7b4818fd27b7b44706fb8122d80a
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100744
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
(cherry picked from commit 091eca0ae421ca436ba95ea1e478909f2a18d0a7)
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/103047
Diffstat (limited to 'loleaflet')
-rw-r--r-- | loleaflet/src/map/handler/Map.TouchGesture.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js index 895977228..689e9104f 100644 --- a/loleaflet/src/map/handler/Map.TouchGesture.js +++ b/loleaflet/src/map/handler/Map.TouchGesture.js @@ -515,6 +515,9 @@ L.Map.TouchGesture = L.Handler.extend({ }, _onPinchStart: function (e) { + if (isNaN(e.center.x) || isNaN(e.center.y)) + return; + this._pinchStartCenter = {x: e.center.x, y: e.center.y}; if (this._map._docLayer.isCursorVisible()) { this._map._docLayer._cursorMarker.setOpacity(0); @@ -537,7 +540,7 @@ L.Map.TouchGesture = L.Handler.extend({ }, _onPinch: function (e) { - if (!this._pinchStartCenter) + if (!this._pinchStartCenter || isNaN(e.center.x) || isNaN(e.center.y)) return; // we need to invert the offset or the map is moved in the opposite direction @@ -554,6 +557,9 @@ L.Map.TouchGesture = L.Handler.extend({ }, _onPinchEnd: function () { + if (!this._pinchStartCenter) + return; + var oldZoom = this._map.getZoom(), zoomDelta = this._zoom - oldZoom, finalZoom = this._map._limitZoom(zoomDelta > 0 ? Math.ceil(this._zoom) : Math.floor(this._zoom)); |