Skip to content

Commit

Permalink
add some delay to allow zoom and center to settle (#3125)
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler authored May 27, 2024
1 parent b742ce2 commit 81db6d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion nicegui/elements/leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export default {
"preclick",
"zoomanim",
]) {
this.map.on(type, (e) => {
this.map.on(type, async (e) => {
await this.$nextTick(); // NOTE: allow zoom and center to both be updated
this.$emit(`map-${type}`, {
...e,
originalEvent: undefined,
Expand Down
6 changes: 4 additions & 2 deletions nicegui/elements/leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ async def initialized(self) -> None:
await self.client.connected()
await event.wait()

def _handle_moveend(self, e: GenericEventArguments) -> None:
async def _handle_moveend(self, e: GenericEventArguments) -> None:
await asyncio.sleep(0.02) # NOTE: wait for zoom to be updated as well
self.center = e.args['center']

def _handle_zoomend(self, e: GenericEventArguments) -> None:
async def _handle_zoomend(self, e: GenericEventArguments) -> None:
await asyncio.sleep(0.02) # NOTE: wait for center to be updated as well
self.zoom = e.args['zoom']

def run_method(self, name: str, *args: Any, timeout: float = 1, check_interval: float = 0.01) -> AwaitableResponse:
Expand Down

0 comments on commit 81db6d7

Please sign in to comment.