Skip to content

Commit 0168018

Browse files
committed
reduce calls to _render() caused by jumpTo()
1 parent 6eeafe9 commit 0168018

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/ui/map.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ const defaultOptions: Readonly<Partial<MapOptions>> = {
424424
maxTileCacheZoomLevels: config.MAX_TILE_CACHE_ZOOM_LEVELS,
425425
transformRequest: null,
426426
transformCameraUpdate: null,
427-
fadeDuration: 300,
427+
fadeDuration: 0,
428428
crossSourceCollisions: true,
429429
clickTolerance: 3,
430430
localIdeographFontFamily: 'sans-serif',
@@ -676,8 +676,17 @@ export class Map extends Camera {
676676
this._setupContainer();
677677
this._setupPainter();
678678

679-
this.on('move', () => this._update(false))
680-
.on('moveend', () => this._update(false))
679+
this.on('moveend', () => {
680+
if (!this.style || !this.style.sourceCaches || !this.transform) {
681+
return;
682+
}
683+
for (const id in this.style.sourceCaches) {
684+
this.style.sourceCaches[id].update(this.transform, this.terrain);
685+
}
686+
if (this.areTilesLoaded()) {
687+
this._update(false);
688+
}
689+
})
681690
.on('zoom', () => this._update(true))
682691
.on('terrain', () => {
683692
this.painter.terrainFacilitator.dirty = true;
@@ -745,6 +754,9 @@ export class Map extends Camera {
745754
}
746755
});
747756
this.on('data', (event: MapDataEvent) => {
757+
if (!this.areTilesLoaded()) {
758+
return;
759+
}
748760
this._update(event.dataType === 'style');
749761
this.fire(new Event(`${event.dataType}data`, event));
750762
});
@@ -3226,6 +3238,11 @@ export class Map extends Camera {
32263238

32273239
this._placementDirty = this.style && this.style._updatePlacement(this.transform, this.showCollisionBoxes, fadeDuration, this._crossSourceCollisions, transformUpdateResult.forcePlacementUpdate);
32283240

3241+
if (this._placementDirty) {
3242+
this.triggerRepaint();
3243+
return this;
3244+
}
3245+
32293246
if (transformUpdateResult.fireProjectionEvent) {
32303247
this.fire(new Event('projectiontransition', transformUpdateResult.fireProjectionEvent));
32313248
}

0 commit comments

Comments
 (0)