From e2f0db85070a728b3c5ae10a1b630301cc505bf6 Mon Sep 17 00:00:00 2001 From: Fritz Lekschas Date: Wed, 11 Dec 2024 10:22:40 -0500 Subject: [PATCH] fix: edge case where `zoomToOrigin` unsets the fixed camera (#203) --- CHANGELOG.md | 4 ++++ src/index.js | 2 +- tests/get-set.test.js | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ddb14e..5a1e09d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.11.3 + +- Fix: catch another edge case where `zoomToOrigin` was unsetting the camera fixed state + ## 1.11.2 - Fix: handle camera fixing better by adding a dedicated prop called `cameraIsFixed`. Previously, the lasso end interaction would unset the camera fixing. ([#94](https://github.com/flekschas/regl-scatterplot/issues/94)) diff --git a/src/index.js b/src/index.js index 05852b0..f9689d4 100644 --- a/src/index.js +++ b/src/index.js @@ -2780,7 +2780,7 @@ const createScatterplot = ( 'transitionEnd', () => { resolve(); - camera.config({ isFixed: false }); + camera.config({ isFixed: cameraIsFixed }); }, 1, ); diff --git a/tests/get-set.test.js b/tests/get-set.test.js index fb27a44..f507d14 100644 --- a/tests/get-set.test.js +++ b/tests/get-set.test.js @@ -661,6 +661,10 @@ test('set({ cameraIsFixed })', async () => { scatterplot.set({ cameraIsFixed: true }); expect(scatterplot.get('cameraIsFixed')).toBe(true); + // Adding this here to triple check that the programmatic zoom does not unset + // the camera fixed state + await scatterplot.zoomToOrigin(); + canvas.dispatchEvent(new WheelEvent('wheel', { deltaY: -100 })); await nextAnimationFrame();