chore: comments and variable renaming
This commit is contained in:
parent
bc44c3f947
commit
82014fe670
@ -7667,13 +7667,12 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
cursorButton === prevState.cursorButton;
|
cursorButton === prevState.cursorButton;
|
||||||
|
|
||||||
// If the state hasn't changed and scrollConstraints didn't just get defined, return null
|
// If the state hasn't changed and scrollConstraints didn't just get defined, return null
|
||||||
if (
|
if (!scrollConstraints || (stateUnchanged && prevState.scrollConstraints)) {
|
||||||
!scrollConstraints ||
|
|
||||||
(stateUnchanged && (prevState.scrollConstraints || !scrollConstraints))
|
|
||||||
) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("fired");
|
||||||
|
|
||||||
// Calculate the maximum possible zoom based on the viewport and scrollable area sizes
|
// Calculate the maximum possible zoom based on the viewport and scrollable area sizes
|
||||||
const scrollableWidth = scrollConstraints.width;
|
const scrollableWidth = scrollConstraints.width;
|
||||||
const scrollableHeight = scrollConstraints.height;
|
const scrollableHeight = scrollConstraints.height;
|
||||||
@ -7707,6 +7706,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
const constrainedScrollCenterY =
|
const constrainedScrollCenterY =
|
||||||
scrollConstraints.y + (scrollableHeight - height / zoom.value) / -2;
|
scrollConstraints.y + (scrollableHeight - height / zoom.value) / -2;
|
||||||
|
|
||||||
|
// We're using a `switch(true)` construction here to handle a set of conditions
|
||||||
|
// that can't be easily grouped into a regular switch statement.
|
||||||
|
// Each case represents a unique combination of cursorButton state and
|
||||||
|
// whether or not we should adjust for a centered view (constrained area is smaller than viewport).
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case cursorButton === "down" && shouldAdjustForCenteredView:
|
case cursorButton === "down" && shouldAdjustForCenteredView:
|
||||||
// case when cursor button is down and we should adjust for centered view
|
// case when cursor button is down and we should adjust for centered view
|
||||||
@ -7761,11 +7764,11 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
constrainedScrollY = Math.min(maxScrollY, Math.max(scrollY, minScrollY));
|
constrainedScrollY = Math.min(maxScrollY, Math.max(scrollY, minScrollY));
|
||||||
|
|
||||||
// Check if the new state differs from the old state
|
// Check if the new state differs from the old state
|
||||||
const stateChanged =
|
// and if the state has changed, update the state and return the new state
|
||||||
|
const isStateChanged =
|
||||||
constrainedScrollX !== scrollX || constrainedScrollY !== scrollY;
|
constrainedScrollX !== scrollX || constrainedScrollY !== scrollY;
|
||||||
|
|
||||||
// If the state has changed, update the state and return the new state
|
if (isStateChanged) {
|
||||||
if (stateChanged) {
|
|
||||||
const constrainedState = {
|
const constrainedState = {
|
||||||
scrollX: constrainedScrollX,
|
scrollX: constrainedScrollX,
|
||||||
scrollY: constrainedScrollY,
|
scrollY: constrainedScrollY,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user