-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
LogoControl cleanup #4842
LogoControl cleanup #4842
Conversation
src/ui/control/logo_control.js
Outdated
this._logoDisplay = true; | ||
} else if (this._logoDisplay && !this._logoRequired()) { | ||
this._container.style.display = 'none'; | ||
this._logoDisplay = false; |
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.
We could simply toggle display like this:
this._container.style.display = this._logoRequired() ? 'block' : 'none'
The state variable this._logoDisplay
seems unnecessary.
src/ui/control/logo_control.js
Outdated
|
||
this._map.on('sourcedata', this._updateLogo); | ||
this._updateLogo(); |
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.
I think updating on add was a good idea. Instead of removing it, how about changing the condition in _updateLogo
to !e || e.sourceDataType === 'metadata')
?
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.
Sure! I actually had that for a second, but after I moved the DOM.create
stuff to onAdd
I didn't think it was necessary anymore. But there is a potential race condition if source fires its metadata
event before the LogoControl is added 👍
8d5fcaf
to
8818af3
Compare
fix #4813
This changes a couple things.
I added a
sourcedata
event firing when a source is removed. This seems in line with the current description in our docs:I also follow @jingsam's recommendation of hiding the LogoControl when no Mapbox sources are present instead of removing it from the DOM.
Launch Checklist