[Libreoffice-commits] online.git: loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Sep 9 01:30:46 UTC 2018
loleaflet/src/map/Map.js | 35 ++++++++++++++++++++++++++++++++---
1 file changed, 32 insertions(+), 3 deletions(-)
New commits:
commit 9bb98ab9cf06c36101467ce23f667a8a625d202c
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Sat Sep 8 21:25:41 2018 -0400
Commit: Henry Castro <hcastro at collabora.com>
CommitDate: Sat Sep 8 21:28:31 2018 -0400
loleaflet: ensure map does not pan on resize
Change-Id: I4644fce70026266798282fbab135aa9c6435e671
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index b5ca2c464..af0945c2a 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -355,12 +355,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,
@@ -804,7 +833,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 () {
More information about the Libreoffice-commits
mailing list