loleaflet/src/map/Map.js |   35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 6c09b94a2a1136f93b039604289866048b8a514e
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Sat Sep 8 21:25:41 2018 -0400
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Tue Sep 11 20:23:57 2018 +0200

    loleaflet: ensure map does not pan on resize
    
    Change-Id: I4644fce70026266798282fbab135aa9c6435e671
    Reviewed-on: https://gerrit.libreoffice.org/60209
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 79d70c5e5..944c9928f 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -350,12 +350,41 @@ L.Map = L.Evented.extend({
                return this.panTo(newCenter, options);
        },
 
-       invalidateSize: function () {
+       invalidateSize: function (options) {
                if (!this._loaded) { return this; }
 
+               options = L.extend({
+                       animate: false,
+                       pan: false
+               }, options === true ? {animate: true} : options);
+
                var oldSize = this.getSize();
                this._sizeChanged = true;
-               var newSize = this.getSize();
+
+               var newSize = this.getSize(),
+                   oldCenter = oldSize.divideBy(2).round(),
+                   newCenter = newSize.divideBy(2).round(),
+                   offset = oldCenter.subtract(newCenter);
+
+               if (!offset.x && !offset.y) { return this; }
+
+               if (options.animate && options.pan) {
+                       this.panBy(offset);
+
+               } else {
+                       if (options.pan) {
+                               this._rawPanBy(offset);
+                       }
+
+                       this.fire('move');
+
+                       if (options.debounceMoveend) {
+                               clearTimeout(this._sizeTimer);
+                               this._sizeTimer = setTimeout(L.bind(this.fire, 
this, 'moveend'), 200);
+                       } else {
+                               this.fire('moveend');
+                       }
+               }
 
                return this.fire('resize', {
                        oldSize: oldSize,
@@ -799,7 +828,7 @@ L.Map = L.Evented.extend({
        _onResize: function () {
                L.Util.cancelAnimFrame(this._resizeRequest);
                this._resizeRequest = L.Util.requestAnimFrame(
-                       function () { this.invalidateSize(); }, this, false, 
this._container);
+                       function () { this.invalidateSize({debounceMoveend: 
true}); }, this, false, this._container);
        },
 
        _activate: function () {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to