From a356d6778fd3a2aeba2f666278a3dbc283867e30 Mon Sep 17 00:00:00 2001 From: Manuel EMERIAU Date: Mon, 20 Oct 2025 10:49:34 +0200 Subject: [PATCH 1/2] test: check if the padding option is keep on a flyTo call when prefers-reduced-motion is set and flyTo calls a jumpTo instead --- src/ui/camera.test.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ui/camera.test.ts b/src/ui/camera.test.ts index 21e7b495672..606eb245dd6 100644 --- a/src/ui/camera.test.ts +++ b/src/ui/camera.test.ts @@ -1287,7 +1287,7 @@ describe('easeTo', () => { stubNow.mockImplementation(() => 0); camera.easeTo({bearing: 97, duration: 500}); - + stubNow.mockImplementation(() => 100); camera.simulateFrame(); @@ -2030,6 +2030,15 @@ describe('flyTo', () => { expect(timeDiff >= 0 && timeDiff < 10).toBeTruthy(); }); + test('applies the padding option when prefers-reduce-motion:reduce is set', async () => { + const camera = createCamera(); + Object.defineProperty(browser, 'prefersReducedMotion', {value: true}); + + camera.flyTo({padding: {top: 50, right: 30}}); + + expect(camera.getPadding()).toEqual({top: 50, bottom: 0, left: 0, right: 30}); + }); + test('check elevation events freezeElevation=false', async () => { const camera = createCamera(); const stub = vi.spyOn(timeControl, 'now'); From f6e3eb290582740e1c7f4ca675825822ac6cdb94 Mon Sep 17 00:00:00 2001 From: Manuel EMERIAU Date: Mon, 20 Oct 2025 11:43:54 +0200 Subject: [PATCH 2/2] fix: when prefers-reduced-motion is set the padding option is now applied on a flyTo --- CHANGELOG.md | 1 + src/ui/camera.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86931dec956..9247783d9b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Contextmenu events not blocked by scrolling ([#5683](https://github.com/maplibre/maplibre-gl-js/issues/5683) - Mousemove events are not blocked by scrolling ([#6302](https://github.com/maplibre/maplibre-gl-js/issues/6302)) - Dashed lines have blurry rounded caps ([#6554](https://github.com/maplibre/maplibre-gl-js/pull/6554)) +- Preserve flyTo padding when prefers-reduced-motion is enabled ([#6576](https://github.com/maplibre/maplibre-gl-js/issues/6576)) ## 5.9.0 diff --git a/src/ui/camera.ts b/src/ui/camera.ts index b4561024d65..735d83946b4 100644 --- a/src/ui/camera.ts +++ b/src/ui/camera.ts @@ -1387,7 +1387,7 @@ export abstract class Camera extends Evented { flyTo(options: FlyToOptions, eventData?: any): this { // Fall through to jumpTo if user has set prefers-reduced-motion if (!options.essential && browser.prefersReducedMotion) { - const coercedOptions = pick(options, ['center', 'zoom', 'bearing', 'pitch', 'roll', 'elevation']) as CameraOptions; + const coercedOptions = pick(options, ['center', 'zoom', 'bearing', 'pitch', 'roll', 'elevation', 'padding']) as JumpToOptions; return this.jumpTo(coercedOptions, eventData); }