experiment with zooming

This commit is contained in:
Ryan Di 2025-05-12 16:24:00 +10:00
parent 2e9c8851b3
commit c84fad4436

View File

@ -3917,9 +3917,21 @@ class App extends React.Component<AppProps, AppState> {
}), }),
}; };
this.setState(constrainScrollState(newState)); this.setState(newState);
if (this.state.scrollConstraints) {
// debounce to allow centering on user's cursor position before constraining
if (newState.zoom.value !== this.state.zoom.value) {
this.debounceConstrainScrollState(newState);
} else {
this.setState(constrainScrollState(newState));
}
}
}; };
private debounceConstrainScrollState = debounce((state: AppState) => {
this.setState(constrainScrollState(state, "rigid"));
}, 500);
private animateToConstrainedArea = ( private animateToConstrainedArea = (
fromValues: AnimateTranslateCanvasValues, fromValues: AnimateTranslateCanvasValues,
toValues: AnimateTranslateCanvasValues, toValues: AnimateTranslateCanvasValues,