From 0f558b3f769c13078e2cc4518f590ec351b7789c Mon Sep 17 00:00:00 2001 From: Anna Peery <42715836+avpeery@users.noreply.github.com> Date: Fri, 18 Mar 2022 12:40:49 -0700 Subject: [PATCH] Disables cooperative gestures when map is fullscreen in Safari (#11619) * Fix fullscreen bug in Safari and add unit test --- src/ui/handler/scroll_zoom.js | 2 +- test/unit/ui/handler/scroll_zoom.test.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ui/handler/scroll_zoom.js b/src/ui/handler/scroll_zoom.js index c3e3e1556c7..5f27fc8f75c 100644 --- a/src/ui/handler/scroll_zoom.js +++ b/src/ui/handler/scroll_zoom.js @@ -398,7 +398,7 @@ class ScrollZoomHandler { } _isFullscreen(): boolean { - return !!window.document.fullscreenElement; + return !!window.document.fullscreenElement || !!window.document.webkitFullscreenElement; } _showBlockerAlert() { diff --git a/test/unit/ui/handler/scroll_zoom.test.js b/test/unit/ui/handler/scroll_zoom.test.js index f3b4f9e938e..cd533f77831 100644 --- a/test/unit/ui/handler/scroll_zoom.test.js +++ b/test/unit/ui/handler/scroll_zoom.test.js @@ -455,6 +455,20 @@ test('When cooperativeGestures option is set to true, scroll zoom is activated w t.end(); }); +test('When cooperativeGestures option is set to true, scroll zoom is not prevented when map is fullscreen', (t) => { + window.document.fullscreenElement = true; + const map = createMapWithCooperativeGestures(t); + + const zoomSpy = t.spy(); + map.on('zoom', zoomSpy); + + simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -simulate.magicWheelZoomDelta}); + map._renderTaskQueue.run(); + + t.equal(zoomSpy.callCount, 1); + t.end(); +}); + test('Disabling scrollZoom removes scroll zoom blocker container', (t) => { const map = createMapWithCooperativeGestures(t);