Skip to content

Commit cdb26fe

Browse files
manuel-emManuel EMERIAUHarelM
authored
On a flyTo call with prefers-reduced-motion set, apply the padding option (#6593)
* test: check if the padding option is keep on a flyTo call when prefers-reduced-motion is set and flyTo calls a jumpTo instead * fix: when prefers-reduced-motion is set the padding option is now applied on a flyTo --------- Co-authored-by: Manuel EMERIAU <[email protected]> Co-authored-by: Harel M <[email protected]>
1 parent 32964f2 commit cdb26fe

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Contextmenu events not blocked by scrolling ([#5683](https://github.com/maplibre/maplibre-gl-js/issues/5683)
1212
- Mousemove events are not blocked by scrolling ([#6302](https://github.com/maplibre/maplibre-gl-js/issues/6302))
1313
- Dashed lines have blurry rounded caps ([#6554](https://github.com/maplibre/maplibre-gl-js/pull/6554))
14+
- Preserve flyTo padding when prefers-reduced-motion is enabled ([#6576](https://github.com/maplibre/maplibre-gl-js/issues/6576))
1415
- Fix setClusterOptions not triggering recluster when no data changes are pending ([#6603](https://github.com/maplibre/maplibre-gl-js/pull/6603))
1516

1617
## 5.9.0

src/ui/camera.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ describe('easeTo', () => {
12871287
stubNow.mockImplementation(() => 0);
12881288

12891289
camera.easeTo({bearing: 97, duration: 500});
1290-
1290+
12911291
stubNow.mockImplementation(() => 100);
12921292
camera.simulateFrame();
12931293

@@ -2030,6 +2030,15 @@ describe('flyTo', () => {
20302030
expect(timeDiff >= 0 && timeDiff < 10).toBeTruthy();
20312031
});
20322032

2033+
test('applies the padding option when prefers-reduce-motion:reduce is set', async () => {
2034+
const camera = createCamera();
2035+
Object.defineProperty(browser, 'prefersReducedMotion', {value: true});
2036+
2037+
camera.flyTo({padding: {top: 50, right: 30}});
2038+
2039+
expect(camera.getPadding()).toEqual({top: 50, bottom: 0, left: 0, right: 30});
2040+
});
2041+
20332042
test('check elevation events freezeElevation=false', async () => {
20342043
const camera = createCamera();
20352044
const stub = vi.spyOn(timeControl, 'now');

src/ui/camera.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ export abstract class Camera extends Evented {
13871387
flyTo(options: FlyToOptions, eventData?: any): this {
13881388
// Fall through to jumpTo if user has set prefers-reduced-motion
13891389
if (!options.essential && browser.prefersReducedMotion) {
1390-
const coercedOptions = pick(options, ['center', 'zoom', 'bearing', 'pitch', 'roll', 'elevation']) as CameraOptions;
1390+
const coercedOptions = pick(options, ['center', 'zoom', 'bearing', 'pitch', 'roll', 'elevation', 'padding']) as JumpToOptions;
13911391
return this.jumpTo(coercedOptions, eventData);
13921392
}
13931393

0 commit comments

Comments
 (0)