mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: remove zoom limit
This commit is contained in:
parent
f82363aae9
commit
381ef93956
1 changed files with 3 additions and 9 deletions
|
@ -7650,7 +7650,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
// Set the overscroll allowance percentage
|
// Set the overscroll allowance percentage
|
||||||
const OVERSCROLL_ALLOWANCE_PERCENTAGE = 0.1;
|
const OVERSCROLL_ALLOWANCE_PERCENTAGE = 0.2;
|
||||||
|
|
||||||
// Check if the state has changed since the last render
|
// Check if the state has changed since the last render
|
||||||
const stateUnchanged =
|
const stateUnchanged =
|
||||||
|
@ -7674,14 +7674,10 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
const scrollableHeight = scrollConstraints.height;
|
const scrollableHeight = scrollConstraints.height;
|
||||||
const maxZoomX = width / scrollableWidth;
|
const maxZoomX = width / scrollableWidth;
|
||||||
const maxZoomY = height / scrollableHeight;
|
const maxZoomY = height / scrollableHeight;
|
||||||
const zoomLimit = Math.min(maxZoomX, maxZoomY);
|
|
||||||
|
|
||||||
// Default scroll and zoom values
|
// Default scroll and zoom values
|
||||||
let constrainedScrollX = scrollX;
|
let constrainedScrollX = scrollX;
|
||||||
let constrainedScrollY = scrollY;
|
let constrainedScrollY = scrollY;
|
||||||
const constrainedZoom = {
|
|
||||||
value: getNormalizedZoom(Math.max(zoom.value, zoomLimit)),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Calculate the overscroll allowance for each axis
|
// Calculate the overscroll allowance for each axis
|
||||||
const overscrollAllowanceX =
|
const overscrollAllowanceX =
|
||||||
|
@ -7740,16 +7736,14 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
|
|
||||||
// Check if the new state differs from the old state
|
// Check if the new state differs from the old state
|
||||||
const stateChanged =
|
const stateChanged =
|
||||||
constrainedScrollX !== scrollX ||
|
constrainedScrollX !== scrollX || constrainedScrollY !== scrollY;
|
||||||
constrainedScrollY !== scrollY ||
|
|
||||||
constrainedZoom.value !== zoom.value;
|
|
||||||
|
|
||||||
// If the state has changed, update the state and return the new state
|
// If the state has changed, update the state and return the new state
|
||||||
if (stateChanged) {
|
if (stateChanged) {
|
||||||
const constrainedState = {
|
const constrainedState = {
|
||||||
scrollX: constrainedScrollX,
|
scrollX: constrainedScrollX,
|
||||||
scrollY: constrainedScrollY,
|
scrollY: constrainedScrollY,
|
||||||
zoom: constrainedZoom,
|
zoom,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setState(constrainedState);
|
this.setState(constrainedState);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue