mirror of
https://github.com/Hypfer/Valetudo.git
synced 2025-10-26 11:27:27 +00:00
fix(ui): Fix zoom level after zooming in and back out again not ending up where it started
This commit is contained in:
parent
8e97f344fb
commit
2e5a9c20bc
@ -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
|
||||
};
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user