Skip to content

Commit

Permalink
Let Popup listen also to 'moveend' in order to fit on screen after a …
Browse files Browse the repository at this point in the history
…resize is detected.

(incidentally, this also makes it impossible to pan a popup out of the view, maybe a resize should simply emit a 'vewreset' and avoid listening of 'moveend')
  • Loading branch information
lapo-luchini committed Oct 9, 2012
1 parent d173d77 commit 6940786
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/layer/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ L.Popup = L.Class.extend({
map._panes.popupPane.appendChild(this._container);

map.on('viewreset', this._updatePosition, this);
map.on('moveend', this._updatePosition, this);

if (L.Browser.any3d) {
map.on('zoomanim', this._zoomAnimation, this);
Expand Down Expand Up @@ -72,6 +73,7 @@ L.Popup = L.Class.extend({

map.off({
viewreset: this._updatePosition,
moveend: this._updatePosition,
preclick: this._close,
zoomanim: this._zoomAnimation
}, this);
Expand Down Expand Up @@ -140,8 +142,6 @@ L.Popup = L.Class.extend({
this._updatePosition();

this._container.style.visibility = '';

this._adjustPan();
},

_updateContent: function () {
Expand Down Expand Up @@ -203,6 +203,8 @@ L.Popup = L.Class.extend({
//Bottom position the popup in case the height of the popup changes (images loading etc)
this._container.style.bottom = this._containerBottom + 'px';
this._container.style.left = this._containerLeft + 'px';

this._adjustPan();
},

_zoomAnimation: function (opt) {
Expand Down

1 comment on commit 6940786

@lapo-luchini
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this doesn't work: if the popup is bigger than the screen it keep bouncing trying desperately to fit.

Please sign in to comment.