mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: use single overscrollAllowance for both axis
This commit is contained in:
parent
f8ba862774
commit
ebbd72e792
1 changed files with 13 additions and 15 deletions
|
@ -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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue