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

Pranam Lashkari (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 6 15:33:01 UTC 2020


 loleaflet/src/map/handler/Map.TouchGesture.js |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

New commits:
commit aea119edb733d69b652a40994b823d912aa8dfae
Author:     Pranam Lashkari <lpranam at collabora.com>
AuthorDate: Tue Feb 11 08:20:47 2020 +0530
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Fri Mar 6 16:32:43 2020 +0100

    Stop unnecessary calculation: ergonomic scrolling
    
    Even when the document reached the boundary,
    autoscrolling function was being called unnecessary
     until certain conditions are met
     this did not cause the document to scroll beyond the boundary
     bu it used to consume some CPU
    
     follow up for: https://gerrit.libreoffice.org/c/online/+/88072
    
    Change-Id: I1cb6d6917c70de18af369d827e986a16eeb50c99
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88421
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index 849f64d69..1fc7479c6 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -637,6 +637,7 @@ L.Map.TouchGesture = L.Handler.extend({
 
 	_autoscroll: function() {
 		var elapsed, delta;
+
 		elapsed = Date.now() - this._timeStamp;
 		delta = this._amplitude.multiplyBy(Math.exp(-elapsed / 325));
 		var e = this._constructFakeEvent({
@@ -646,13 +647,24 @@ L.Map.TouchGesture = L.Handler.extend({
 		}, 'mousemove');
 		e.autoscroll = true;
 		if (delta.x > 0.2 || delta.x < -0.2 || delta.y > 0.2 || delta.y < -0.2) {
+			var org = this._map.getPixelOrigin();
+			var docSize = this._map.getLayerMaxBounds().getSize().subtract(this._map.getSize());
+			var horizontalEnd, verticalEnd;
+
 			if (this._map.getDocSize().x < this._map.getSize().x) {
 				//don't scroll horizontally if document fits the view
 				delta.x = 0;
+				horizontalEnd = true;
+			} else {
+				horizontalEnd = Math.max(Math.min(org.x, this._newPos.x), org.x - Math.max(docSize.x, 0)) !== this._newPos.x;
 			}
+
 			if (this._map.getDocSize().y < this._map.getSize().y) {
 				//don't scroll vertically if document fits the view
 				delta.y = 0;
+				verticalEnd = true;
+			} else {
+				verticalEnd = Math.max(Math.min(org.y, this._newPos.y), org.y - Math.max(docSize.y, 0)) !== this._newPos.y;
 			}
 
 			this._map.dragging._draggable._startPoint = this._startSwipePoint;
@@ -666,7 +678,9 @@ L.Map.TouchGesture = L.Handler.extend({
 			this._map._docLayer._preFetchBorder = null;
 			this._map._docLayer._preFetchTiles();
 
-			this.autoscrollAnimReq = L.Util.requestAnimFrame(this._autoscroll, this, true);
+			if (!horizontalEnd || !verticalEnd) {
+				this.autoscrollAnimReq = L.Util.requestAnimFrame(this._autoscroll, this, true);
+			}
 		}
 		else {
 			this._map.dragging._draggable._onUp(e);


More information about the Libreoffice-commits mailing list