feat: use single overscrollAllowance for both axis

This commit is contained in:
Arnošt Pleskot 2023-09-04 11:55:14 +02:00
parent f8ba862774
commit ebbd72e792
No known key found for this signature in database

View file

@ -8411,7 +8411,8 @@ class App extends React.Component<AppProps, AppState> {
OVERSCROLL_ALLOWANCE_PERCENTAGE * scrollConstraints.width; OVERSCROLL_ALLOWANCE_PERCENTAGE * scrollConstraints.width;
const overscrollAllowanceY = const overscrollAllowanceY =
OVERSCROLL_ALLOWANCE_PERCENTAGE * scrollConstraints.height; OVERSCROLL_ALLOWANCE_PERCENTAGE * scrollConstraints.height;
return { overscrollAllowanceX, overscrollAllowanceY };
return Math.min(overscrollAllowanceX, overscrollAllowanceY);
}; };
/** /**
@ -8425,8 +8426,7 @@ class App extends React.Component<AppProps, AppState> {
*/ */
const calculateMinMaxScrollValues = ( const calculateMinMaxScrollValues = (
shouldAdjustForCenteredView: boolean, shouldAdjustForCenteredView: boolean,
overscrollAllowanceX: number, overscrollAllowance: number,
overscrollAllowanceY: number,
constrainedScrollCenterX: number, constrainedScrollCenterX: number,
constrainedScrollCenterY: number, constrainedScrollCenterY: number,
zoom: number, zoom: number,
@ -8437,23 +8437,23 @@ class App extends React.Component<AppProps, AppState> {
let minScrollY; let minScrollY;
if (cursorButton === "down" && shouldAdjustForCenteredView) { if (cursorButton === "down" && shouldAdjustForCenteredView) {
maxScrollX = constrainedScrollCenterX + overscrollAllowanceX; maxScrollX = constrainedScrollCenterX + overscrollAllowance;
minScrollX = constrainedScrollCenterX - overscrollAllowanceX; minScrollX = constrainedScrollCenterX - overscrollAllowance;
maxScrollY = constrainedScrollCenterY + overscrollAllowanceY; maxScrollY = constrainedScrollCenterY + overscrollAllowance;
minScrollY = constrainedScrollCenterY - overscrollAllowanceY; minScrollY = constrainedScrollCenterY - overscrollAllowance;
} else if (cursorButton === "down" && !shouldAdjustForCenteredView) { } else if (cursorButton === "down" && !shouldAdjustForCenteredView) {
maxScrollX = scrollConstraints.x + overscrollAllowanceX; maxScrollX = scrollConstraints.x + overscrollAllowance;
minScrollX = minScrollX =
scrollConstraints.x - scrollConstraints.x -
scrollConstraints.width + scrollConstraints.width +
width / zoom - width / zoom -
overscrollAllowanceX; overscrollAllowance;
maxScrollY = scrollConstraints.y + overscrollAllowanceY; maxScrollY = scrollConstraints.y + overscrollAllowance;
minScrollY = minScrollY =
scrollConstraints.y - scrollConstraints.y -
scrollConstraints.height + scrollConstraints.height +
height / zoom - height / zoom -
overscrollAllowanceY; overscrollAllowance;
} else if (cursorButton !== "down" && shouldAdjustForCenteredView) { } else if (cursorButton !== "down" && shouldAdjustForCenteredView) {
maxScrollX = constrainedScrollCenterX; maxScrollX = constrainedScrollCenterX;
minScrollX = constrainedScrollCenterX; minScrollX = constrainedScrollCenterX;
@ -8481,15 +8481,13 @@ class App extends React.Component<AppProps, AppState> {
); );
const { constrainedScrollCenterX, constrainedScrollCenterY } = const { constrainedScrollCenterX, constrainedScrollCenterY } =
calculateConstrainedScrollCenter(constrainedZoom); calculateConstrainedScrollCenter(constrainedZoom);
const { overscrollAllowanceX, overscrollAllowanceY } = const overscrollAllowance = calculateOverscrollAllowance();
calculateOverscrollAllowance();
const shouldAdjustForCenteredView = const shouldAdjustForCenteredView =
constrainedZoom <= zoomLevelX || constrainedZoom <= zoomLevelY; constrainedZoom <= zoomLevelX || constrainedZoom <= zoomLevelY;
const { maxScrollX, minScrollX, maxScrollY, minScrollY } = const { maxScrollX, minScrollX, maxScrollY, minScrollY } =
calculateMinMaxScrollValues( calculateMinMaxScrollValues(
shouldAdjustForCenteredView, shouldAdjustForCenteredView,
overscrollAllowanceX, overscrollAllowance,
overscrollAllowanceY,
constrainedScrollCenterX, constrainedScrollCenterX,
constrainedScrollCenterY, constrainedScrollCenterY,
constrainedZoom, constrainedZoom,