commit b46d93b705e2a7b807e4011cac09133eb7c0efd4
parent 2987e862540b80b2b1920618e28e6185ca74c146
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Thu, 3 Aug 2017 01:31:49 +0300
[wikimedia photos] try to avoid race condition when expanding viewer container and fallback to fixed size
Diffstat:
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/lib/leaflet.control.panoramas/index.js b/src/lib/leaflet.control.panoramas/index.js
@@ -204,7 +204,7 @@ L.Control.Panoramas = L.Control.extend({
}
if (data) {
// wait for panorama container become of right size, needed for viewer setup
- setTimeout(() => provider.viewer.showPano(data), 0);
+ L.Util.requestAnimFrame(() => provider.viewer.showPano(data));
}
provider.viewer.activate();
this.notifyChanged();
diff --git a/src/lib/leaflet.control.panoramas/lib/wikimedia/index.js b/src/lib/leaflet.control.panoramas/lib/wikimedia/index.js
@@ -197,7 +197,10 @@ const Viewer = L.Evented.extend({
this.map.removeLayer(this.imageLayer);
}
let image = this.images[imageIdx];
- const mapSize = this.map.getSize();
+ let mapSize = this.map.getSize();
+ if (!mapSize.x || !mapSize.y) {
+ mapSize = {x: 500, y: 500}
+ }
let maxZoom = Math.log2(Math.max(image.width / mapSize.x, image.height / mapSize.y)) + 2;
if (maxZoom < 1) {
maxZoom = 1;