New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up DOM event listeners when destroying Map's animation proxy #9048
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making this PR. Can you please apply the requested changes.
Can you please move this code into a function _animateProxyZoom
and then remove the zoomanim
event in _destroyAnimProxy
too. this.on('zoomanim',this._animateProxyZoom, this);
Lines 1629 to 1638 in 847fbb4
this.on('zoomanim', function (e) { | |
const transform = this._proxy.style.transform; | |
DomUtil.setTransform(this._proxy, this.project(e.center, e.zoom), this.getZoomScale(e.zoom, 1)); | |
// workaround for case when transform is the same and so transitionend event is not fired | |
if (transform === this._proxy.style.transform && this._animatingZoom) { | |
this._onZoomTransitionEnd(); | |
} | |
}, this); |
src/map/Map.js
Outdated
@@ -1643,6 +1643,7 @@ export const Map = Evented.extend({ | |||
}, | |||
|
|||
_destroyAnimProxy() { | |||
DomEvent.off(this._proxy, 'transitionend', this._catchTransitionEnd, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DomEvent.off(this._proxy, 'transitionend', this._catchTransitionEnd, this); |
Please move this line into the remove
function after the event unload
:
Lines 775 to 780 in 847fbb4
if (this._loaded) { | |
// @section Map state change events | |
// @event unload: Event | |
// Fired when the map is destroyed with [remove](#map-remove) method. | |
this.fire('unload'); | |
} |
@Falke-Design May I simply add a |
@Falke-Design I made the following changes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
@jonkoops Pinging because it has been almost 3 months. Can this fix be merged? |
In the constructor for
Map
, a listener is added for the'transitionend'
event of the animation proxy element (if zoom animation is enabled):This PR adds a
DomEvent.off()
call to clean up that listener inside of theMap._destroyAnimProxy()
method.Closes #9046.