From 95667c159e391233c4836163e847426bd8d8ee6b Mon Sep 17 00:00:00 2001 From: Andrew Olsen Date: Fri, 5 Apr 2024 08:00:24 +1100 Subject: [PATCH] Fix for #3935 - add test, update CHANGELOG --- CHANGELOG.md | 2 +- src/render/terrain.test.ts | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b3f25174e..87b253d03d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - Added const enum for actor messages to improve readability and maintainability. In tsconfig.json, `isolatedModules` flag is set to false in favor of generated JS size. ([#3879](https://github.com/maplibre/maplibre-gl-js/issues/3879)) ### 🐞 Bug fixes -- _...Add new stuff here..._ +- Fix different unwanted panning changes at the end of a panning motion, that happen on a large screen ([#3935](https://github.com/maplibre/maplibre-gl-js/issues/3935)) ## 4.1.2 diff --git a/src/render/terrain.test.ts b/src/render/terrain.test.ts index 22c4d4250a..befcab698e 100644 --- a/src/render/terrain.test.ts +++ b/src/render/terrain.test.ts @@ -65,14 +65,14 @@ describe('Terrain', () => { }); - const setupMercatorOverflow = () => { + const setupMercatorOverflow = (pixelRatio: number = 1) => { const WORLD_WIDTH = 4; const painter = { context: new Context(gl), width: WORLD_WIDTH, height: 1, - pixelRatio: 1, maybeDrawDepthAndCoords: jest.fn(), + pixelRatio, } as any as Painter; const sourceCache = {} as SourceCache; const terrain = new Terrain(painter, sourceCache, {} as any as TerrainSpecification); @@ -91,7 +91,7 @@ describe('Terrain', () => { rgba[0] = 0; rgba[1] = 0; rgba[2] = 0; - rgba[3] = 255 - x; + rgba[3] = 255 - x / pixelRatio; }); return terrain; }; @@ -122,6 +122,22 @@ describe('Terrain', () => { expect(terrain.painter.maybeDrawDepthAndCoords).toHaveBeenCalled(); }); + test( + 'pointCoordinate should respect painter.pixelRatio', + () => { + const terrain = setupMercatorOverflow(2); + + let pointX = 0; + let coordinate = terrain.pointCoordinate(new Point(pointX, 0)); + expect(coordinate.x).toBe(-1); + expect(terrain.painter.maybeDrawDepthAndCoords).toHaveBeenCalled(); + + pointX = 3; + coordinate = terrain.pointCoordinate(new Point(pointX, 0)); + expect(coordinate.x).toBe(2); + expect(terrain.painter.maybeDrawDepthAndCoords).toHaveBeenCalled(); + }); + test('Calculate tile minimum and maximum elevation', () => { const tileID = new OverscaledTileID(5, 0, 5, 17, 11); const tile = new Tile(tileID, 256);