Skip to content

Commit

Permalink
fix(ui): Fix zoom level after zooming in and back out again not endin…
Browse files Browse the repository at this point in the history
…g up where it started
  • Loading branch information
vivia authored and Hypfer committed Sep 28, 2024
1 parent 8e97f34 commit 2e5a9c2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions frontend/src/map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export const MapContainer = styled(Box)({
});

const SCROLL_PARAMETERS = {
ZOOM_IN_MULTIPLIER: 4/3 - 1,
ZOOM_OUT_MULTIPLIER: 1 - 3/4,
ZOOM_MULTIPLIER: 1/4,
PIXELS_PER_FULL_STEP: 100
};

Expand Down Expand Up @@ -476,9 +475,13 @@ abstract class Map<P, S> extends React.Component<P & MapProps, S & MapState > {
}
}, 250);


const fullStep = evt.deltaY < 0 ? SCROLL_PARAMETERS.ZOOM_IN_MULTIPLIER : SCROLL_PARAMETERS.ZOOM_OUT_MULTIPLIER;
let factor = 1 - (fullStep * (evt.deltaY / SCROLL_PARAMETERS.PIXELS_PER_FULL_STEP));
const scaledPixels = evt.deltaY * (SCROLL_PARAMETERS.ZOOM_MULTIPLIER / SCROLL_PARAMETERS.PIXELS_PER_FULL_STEP);
let factor;
if (evt.deltaY < 0) {
factor = 1 / (1 + scaledPixels);
} else {
factor = 1 - scaledPixels;
}

const { scaleX: currentScaleFactor } = this.ctxWrapper.getScaleFactor();

Expand Down

0 comments on commit 2e5a9c2

Please sign in to comment.