loleaflet/src/layer/tile/CanvasTileLayer.js   |   35 +++++++++++++++++++++-----
 loleaflet/src/map/anim/Map.ZoomAnimation.js   |    2 -
 loleaflet/src/map/handler/Map.TouchGesture.js |   12 ++------
 3 files changed, 34 insertions(+), 15 deletions(-)

New commits:
commit 8d9b6f3e8ccea4e6edc26a233ebbe99161f58973
Author:     Jan Holesovsky <[email protected]>
AuthorDate: Tue Sep 8 14:28:02 2020 +0200
Commit:     Jan Holesovsky <[email protected]>
CommitDate: Tue Sep 8 15:09:58 2020 +0200

    calc canvas: Move the canvas during the pinch-to-zoom.
    
    The actual zooming is still missing.
    
    Change-Id: I68f01fee025589952ee4044e7f64caa1c29ee68f

diff --git a/loleaflet/src/layer/tile/CanvasTileLayer.js 
b/loleaflet/src/layer/tile/CanvasTileLayer.js
index e44593a9d..4a35b4939 100644
--- a/loleaflet/src/layer/tile/CanvasTileLayer.js
+++ b/loleaflet/src/layer/tile/CanvasTileLayer.js
@@ -180,6 +180,13 @@ L.CanvasTilePainter = L.Class.extend({
                        this._canvasCtx.scale(1, 1);
                        this._canvasCtx.translate(-topLeft.x, -topLeft.y);
 
+                       // when using the pinch to zoom, set additional 
translation based
+                       // on the pinch movement
+                       if (this._map._animatingZoom) {
+                               var centerOffset = 
this._map._getCenterOffset(this._map._animateToCenter);
+                               
this._canvasCtx.translate(-Math.round(centerOffset.x), 
-Math.round(centerOffset.y));
+                       }
+
                        // create a clip for the pane/view.
                        this._canvasCtx.beginPath();
                        var paneSize = paneBounds.getSize();
@@ -475,8 +482,10 @@ L.CanvasTileLayer = L.TileLayer.extend({
        _animateZoom: function (e) {
                var oldAnimatingZoom = this._map._animatingZoom;
                var oldAnimateToZoom = this._map._animateToZoom;
+               var oldAnimateToCenter = this._map._animateToCenter;
                this._map._animatingZoom = true;
                this._map._animateToZoom = e.zoom;
+               this._map._animateToCenter = e.center;
 
                this._update(e.center, e.zoom);
                this._resetPreFetching(true);
@@ -485,6 +494,7 @@ L.CanvasTileLayer = L.TileLayer.extend({
 
                this._map._animatingZoom = oldAnimatingZoom;
                this._map._animateToZoom = oldAnimateToZoom;
+               this._map._animateToCenter = oldAnimateToCenter;
        },
 
        _setZoomTransforms: function () {
commit 7d69c3d55ea49fb10cf0abf20f6997e71cb17974
Author:     Jan Holesovsky <[email protected]>
AuthorDate: Tue Sep 8 12:21:04 2020 +0200
Commit:     Jan Holesovsky <[email protected]>
CommitDate: Tue Sep 8 15:09:58 2020 +0200

    calc canvas: Paint to canvas during the pinch-to-zoom.
    
    Infrastructure work, so that the updates are triggered during that.
    
    Change-Id: I88e75cdc32047a487dd23c9e7be792b14dc097f0

diff --git a/loleaflet/src/layer/tile/CanvasTileLayer.js 
b/loleaflet/src/layer/tile/CanvasTileLayer.js
index 6d6aacecd..e44593a9d 100644
--- a/loleaflet/src/layer/tile/CanvasTileLayer.js
+++ b/loleaflet/src/layer/tile/CanvasTileLayer.js
@@ -8,6 +8,7 @@ L.TileCoordData = L.Class.extend({
        initialize: function (left, top, zoom, part) {
                this.x = left;
                this.y = top;
+               // FIXME console.assert(Number.isInteger(zoom));
                this.z = zoom;
                this.part = part;
        },
@@ -215,7 +216,6 @@ L.CanvasTilePainter = L.Class.extend({
        },
 
        update: function () {
-
                var newDpiScale = L.getDpiScaleFactor(true /* useExactDPR */);
                var scaleChanged = this._dpiScale != newDpiScale;
 
@@ -225,7 +225,7 @@ L.CanvasTilePainter = L.Class.extend({
                }
 
                var splitPanesContext = this._layer.getSplitPanesContext();
-               var zoom = Math.round(this._map.getZoom());
+               var zoom = this._map.getZoom();
                var pixelBounds = this._map.getPixelBounds();
                var newMapSize = pixelBounds.getSize();
                var newTopLeft = pixelBounds.getTopLeft();
@@ -272,7 +272,8 @@ L.CanvasTilePainter = L.Class.extend({
                if (splitPosChanged)
                        this._splitPos = newSplitPos;
 
-               this._lastZoom = zoom;
+               if (!this._map._animatingZoom)
+                       this._lastZoom = Math.round(zoom);
                this._lastPart = part;
 
                this._topLeft = newTopLeft;
@@ -412,12 +413,12 @@ L.CanvasTileLayer = L.TileLayer.extend({
                        movestart: this._moveStart,
                        moveend: this._move,
                        // update tiles on move, but not more often than once 
per given interval
-                       move: L.Util.throttle(this._move, 
this.options.updateInterval, this),
+                       move: L.Util.throttle(this._move, 
this.options.updateInterval, this), // TODO we might want to make the updates 
more often (?)
                        splitposchanged: this._move,
                };
 
                if (this._zoomAnimated) {
-                       events.zoomanim = this._animateZoom;
+                       events.zoomanim = L.Util.throttle(this._animateZoom, 
this.options.updateInterval, this); // TODO we might want to make the updates 
more often (?)
                }
 
                return events;
@@ -471,7 +472,19 @@ L.CanvasTileLayer = L.TileLayer.extend({
                }
        },
 
-       _animateZoom: function () {
+       _animateZoom: function (e) {
+               var oldAnimatingZoom = this._map._animatingZoom;
+               var oldAnimateToZoom = this._map._animateToZoom;
+               this._map._animatingZoom = true;
+               this._map._animateToZoom = e.zoom;
+
+               this._update(e.center, e.zoom);
+               this._resetPreFetching(true);
+               this._onCurrentPageUpdate();
+               this._painter.update(this._painter);
+
+               this._map._animatingZoom = oldAnimatingZoom;
+               this._map._animateToZoom = oldAnimateToZoom;
        },
 
        _setZoomTransforms: function () {
diff --git a/loleaflet/src/map/anim/Map.ZoomAnimation.js 
b/loleaflet/src/map/anim/Map.ZoomAnimation.js
index 5d6ceaec5..5b0b9ec1a 100644
--- a/loleaflet/src/map/anim/Map.ZoomAnimation.js
+++ b/loleaflet/src/map/anim/Map.ZoomAnimation.js
@@ -8,7 +8,7 @@ L.Map.mergeOptions({
        zoomAnimationThreshold: 4
 });
 
-var zoomAnimated = false;//L.DomUtil.TRANSITION && L.Browser.any3d && 
!L.Browser.mobileOpera && !(this._docLayer instanceof L.CanvasTileLayer);
+var zoomAnimated = L.DomUtil.TRANSITION && L.Browser.any3d && 
!L.Browser.mobileOpera && !(this._docLayer instanceof L.CanvasTileLayer);
 
 if (zoomAnimated) {
 
diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js 
b/loleaflet/src/map/handler/Map.TouchGesture.js
index fd81d9b37..bcbc471f1 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -549,10 +549,8 @@ L.Map.TouchGesture = L.Handler.extend({
 
                L.Util.cancelAnimFrame(this._animRequest);
                this._animRequest = L.Util.requestAnimFrame(function () {
-                       if (typeof this._map._animateZoom === 'function')
-                               this._map._animateZoom(this._center, 
this._zoom, false, true);
-                       else
-                               this._map._resetView(this._center, this._zoom, 
false, true);
+                       console.assert(typeof this._map._animateZoom === 
'function');
+                       this._map._animateZoom(this._center, this._zoom, false, 
true);
                }, this, true, this._map._container);
        },
 
@@ -576,10 +574,8 @@ L.Map.TouchGesture = L.Handler.extend({
 
                if (this._center) {
                        L.Util.cancelAnimFrame(this._animRequest);
-                       if (typeof this._map._animateZoom === 'function')
-                               this._map._animateZoom(this._center, finalZoom, 
true, true);
-                       else
-                               this._map._resetView(this._center, finalZoom, 
false, true);
+                       console.assert(typeof this._map._animateZoom === 
'function');
+                       this._map._animateZoom(this._center, finalZoom, true, 
true);
                }
 
                if (this._map._docLayer && this._map._docLayer._annotations) {
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to