map jiggles after setMaxBounds

12 views
Skip to first unread message

Linus Kamb

unread,
Jan 19, 2018, 12:48:35 PM1/19/18
to Leaflet
Hi,

In certain cases, my maps jiggle back and forth forever until I resize the window.

I don't know the specific situation that causes some maps to jiggle and other not to, but the jiggling happens after a call to map.setMaxBounds();

The jiggling is due to a repeating loop between _panInsideBounds and _onPanTransitionEnd.

I am using version Leaflet 1.2.0+Detached: 1ac320ba232cb85b73ac81f3d82780c9d07f0d4e.1ac320b

What happens is:

in response to setMaxBounds, _panInsideMaxBounds is called.
in _panInsideMaxBounds, it checks for ! _enforcingBounds and if not, calls panInsideBounds (Map.js:1211)
that eventually leads to _onPanTransitionEnd, which fires a 'moveend' event (Map.js:1512)
after firing that event, the code winds up back in _panInsideMaxBounds, checks the _enforcingBounds flag again, and repeats.

I can make it stop by manually changing _enforcingBounds to true before firing the moveend event in _onPanTransitionEnd.

Not all maps do this.  I open tabs with detail maps of certain areas.  The map content pane is the same size for each detail area, but the size of the displayed area differs, ie different zoom levels to accommodate different displayed bounds.

Resizing the browser window by any amount will stop the jiggling on the current map.


Thoughts?  Suggestions?

thanks,
Linus

Reply all
Reply to author
Forward
0 new messages