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

Allow user to define element other than map container for full screen control #7548

Merged
merged 4 commits into from
Nov 13, 2018

Conversation

ryanhamley
Copy link
Contributor

fixes #7544

Launch Checklist

The intended use case is for displaying a map with an overlaid element that works with the map, such as radio buttons to toggle styles or a banner element with a legend. The current behavior of making the map container element full screen will not show these elements. I can't really think of any particular reason to disallow this behavior but let me know if there's a reason not to implement this.

Full screen with {source: body}
screen shot 2018-11-02 at 12 40 43 pm

Default behavior (notice that the debug control in the upper left corner is not displayed)
screen shot 2018-11-02 at 12 42 00 pm

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

this._fullscreen = false;
if (options && options.source) {
this._source = window.document.querySelector(options.source);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our other APIs that need an HTML element reference, such as Map container and Marker element, accept an HTMLElement rather than a selector — I'd suggest keeping this consistent.

@ryanhamley ryanhamley force-pushed the enable-fullscreen-source-option branch from 80fb8e8 to 4ac4092 Compare November 8, 2018 19:51
Copy link
Contributor

@mollymerp mollymerp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Can you add a unit tests that checks that the constructor works as expected when passed a source / container element.

src/ui/control/fullscreen_control.js Outdated Show resolved Hide resolved
@ryanhamley
Copy link
Contributor Author

Added a unit test and changed source option to container and the previous _container internal property to _controlContainer to disambiguate them.

Copy link
Contributor

@mollymerp mollymerp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

const control = map._controls.find((ctrl) => {
return ctrl.hasOwnProperty('_fullscreen');
});
control._onClickFullscreen();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe set a spy on body.requestFullscreen and then check t.calledOnce after this?

Copy link
Contributor Author

@ryanhamley ryanhamley Nov 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something but it doesn't seem like JSDOM supports the Full Screen API. I don't see any documentation or code that mentions it and window.document.requestFullScreen and body.requestFullScreen are both undefined (along with their prefixed alternatives) in the context of the test suite.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh ok nvm then!

@ryanhamley ryanhamley merged commit 361769f into master Nov 13, 2018
@ryanhamley ryanhamley deleted the enable-fullscreen-source-option branch November 13, 2018 22:31
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.

Allow FullscreenControl to specify a source
3 participants