Skip to content
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

Merged
merged 4 commits into from
Jul 7, 2017
Merged

LogoControl cleanup #4842

merged 4 commits into from
Jul 7, 2017

Conversation

mollymerp
Copy link
Contributor

@mollymerp mollymerp commented Jun 16, 2017

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:

Fired when one of the map's sources loads or changes

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

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

this._logoDisplay = true;
} else if (this._logoDisplay && !this._logoRequired()) {
this._container.style.display = 'none';
this._logoDisplay = false;
Copy link
Contributor

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.


this._map.on('sourcedata', this._updateLogo);
this._updateLogo();
Copy link
Contributor

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')?

Copy link
Contributor Author

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 👍

@jfirebaugh jfirebaugh force-pushed the logocontrol-cleanup branch from 8d5fcaf to 8818af3 Compare July 7, 2017 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There was an addtional div when LogoControl was removed
3 participants