Skip to content

Commit

Permalink
Add a tooltip to FullscreenControl (#8012)
Browse files Browse the repository at this point in the history
* Add a tooltip to FullscreenControl and update it when the map enters/exits fullscreen mode

* Fix tooltip text for FullscreenControl
  • Loading branch information
dmytro-gokun authored and andrewharvey committed Mar 13, 2019
1 parent c189971 commit dfead0f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ui/control/fullscreen_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ class FullscreenControl {

_setupUI() {
const button = this._fullscreenButton = DOM.create('button', (`${this._className}-icon ${this._className}-fullscreen`), this._controlContainer);
button.setAttribute("aria-label", "Toggle fullscreen");
button.type = 'button';
this._updateTitle();
this._fullscreenButton.addEventListener('click', this._onClickFullscreen);
window.document.addEventListener(this._fullscreenchange, this._changeIcon);
}

_updateTitle() {
const title = this._isFullscreen() ? "Exit fullscreen" : "Enter fullscreen";
this._fullscreenButton.setAttribute("aria-label", title);
this._fullscreenButton.title = title;
}

_isFullscreen() {
return this._fullscreen;
}
Expand All @@ -108,6 +114,7 @@ class FullscreenControl {
this._fullscreen = !this._fullscreen;
this._fullscreenButton.classList.toggle(`${this._className}-shrink`);
this._fullscreenButton.classList.toggle(`${this._className}-fullscreen`);
this._updateTitle();
}
}

Expand Down

0 comments on commit dfead0f

Please sign in to comment.