Skip to content

Commit 93ba060

Browse files
authored
remove map animation when remove (#2526)
* remove map animation when remove * fixing
1 parent ddd905e commit 93ba060

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

packages/maptalks/src/map/Map.Anim.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ declare module "./Map" {
99
interface Map {
1010
//@internal
1111
_mapAnimPlayer: Player;
12+
//@internal
13+
_animPlayer: Player;
1214
isRotating(): boolean;
1315
//@internal
1416
_animateTo(view: MapViewType, options?: MapAnimationOptionsType, step?: (frame) => void): Player;

packages/maptalks/src/map/Map.Zoom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Map.include(/** @lends Map.prototype */{
114114
scale = fromRes / res / startScale,
115115
startPoint = this._startZoomCoord && this.prjToContainerPoint(this._startZoomCoord, this._startZoomVal);
116116
const offset = this.getViewPoint();
117-
if (!this.isRotating() && startPoint && !startPoint.equals(origin) && scale !== 1) {
117+
if (!this.isRotating() && startPoint && origin && !startPoint.equals(origin) && scale !== 1) {
118118
const pitch = this.getPitch();
119119
// coordinate at origin changed, usually by map.setCenter
120120
// add origin offset

packages/maptalks/src/map/Map.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,6 +1759,13 @@ export class Map extends Handlerable(Eventable(Renderable(Class))) {
17591759
return this;
17601760
}
17611761
this._fireEvent('removestart');
1762+
//remove animation when map removed
1763+
const animationPlayerList = [this._animPlayer, this._mapAnimPlayer];
1764+
animationPlayerList.forEach(player => {
1765+
if (player && player.finish) {
1766+
this._stopAnim(player);
1767+
}
1768+
});
17621769
this._removeDomEvents();
17631770
this._clearHandlers();
17641771
this.removeBaseLayer();

0 commit comments

Comments
 (0)