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

Disables cooperative gestures when map is fullscreen in Safari #11619

Merged
merged 11 commits into from
Mar 18, 2022

Conversation

avpeery
Copy link
Contributor

@avpeery avpeery commented Mar 18, 2022

Closes #11607. When a map is full screen, cooperative gestures should be disabled - this is more user-friendly as the presumption is that the user will want to only interact with the fullscreen map (e.g. not scroll to other content on the screen). This is expected behavior and works in other browsers. Recently discovered while testing Safari 15.4 that cooperative gestures continued to be enabled when map is fullscreen. It was believed that this was working prior (see PR #11086), but is also not working in 15.3.

Added unit test that mocks fullscreenElement, doesn't necessarily address this problem with safari but was a previously missing unit test that checks scroll zoom happens when map is full screen.

Launch Checklist

  • briefly describe the changes in this PR
  • include before/after visuals or gifs if this PR includes visual changes
  • write tests for all new functionality
  • manually test the debug page
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog>Fixes disabling cooperative gestures when map is fullscreen in Safari.</changelog>

@avpeery avpeery requested a review from ansis March 18, 2022 17:44
@@ -398,6 +398,7 @@ class ScrollZoomHandler {
}

_isFullscreen(): boolean {
if (isSafari(window)) return !!window.document.webkitFullscreenElement;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This looks like it should work fine, but it might be a tiny bit cleaner to remove isSafari(...) and just always check for webkitFullScreenElement:
return !!window.document.fullscreenElement || !!window.document.webkitFullscreenElement.

@@ -3,7 +3,7 @@
import assert from 'assert';
import * as DOM from '../../util/dom.js';

import {ease as _ease, bindAll, bezier} from '../../util/util.js';
import {ease as _ease, bindAll, bezier, isSafari} from '../../util/util.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

isSafari is unused now which is causing a lint error

@avpeery avpeery requested review from ryanhamley and ansis March 18, 2022 19:09
Copy link
Contributor

@ansis ansis left a comment

Choose a reason for hiding this comment

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

Looks good to merge once lint passes!

@avpeery avpeery merged commit 0f558b3 into main Mar 18, 2022
@avpeery avpeery deleted the avpeery/fix-fullscreen-safari branch March 18, 2022 19:40
avpeery added a commit that referenced this pull request Mar 18, 2022
* Fix fullscreen bug in Safari and add unit test
avpeery added a commit that referenced this pull request Mar 18, 2022
* Disables antialias for 15.4/15.5 iOS and M1 devices and provides a console warning (#11615)
* Disables cooperative gestures when map is fullscreen in Safari (#11619)

Co-authored-by: Ansis Brammanis <ansis@mapbox.com>
ahocevar pushed a commit to ahocevar/mapbox-gl-js that referenced this pull request Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cooperative gesture handling should not activate when map is full screen (Safari 15.4)
3 participants