lint
This commit is contained in:
@@ -4,9 +4,10 @@ import { Excalidraw } from "@excalidraw/excalidraw";
|
|||||||
|
|
||||||
import "@excalidraw/excalidraw/index.css";
|
import "@excalidraw/excalidraw/index.css";
|
||||||
|
|
||||||
import App from "../../with-script-in-browser/components/ExampleApp";
|
|
||||||
import type { ScrollConstraints } from "@excalidraw/excalidraw/types";
|
import type { ScrollConstraints } from "@excalidraw/excalidraw/types";
|
||||||
|
|
||||||
|
import App from "../../with-script-in-browser/components/ExampleApp";
|
||||||
|
|
||||||
const scrollConstraints: ScrollConstraints = {
|
const scrollConstraints: ScrollConstraints = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
@@ -25,9 +26,7 @@ const ExcalidrawWrapper: React.FC = () => {
|
|||||||
useCustom={(api: any, args?: any[]) => {}}
|
useCustom={(api: any, args?: any[]) => {}}
|
||||||
excalidrawLib={excalidrawLib}
|
excalidrawLib={excalidrawLib}
|
||||||
>
|
>
|
||||||
<Excalidraw
|
<Excalidraw scrollConstraints={scrollConstraints} />
|
||||||
// scrollConstraints={scrollConstraints}
|
|
||||||
/>
|
|
||||||
</App>
|
</App>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4531,18 +4531,16 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
this.setState({ shouldCacheIgnoreZoom: false });
|
this.setState({ shouldCacheIgnoreZoom: false });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else if (scrollConstraints) {
|
||||||
|
this.setState({
|
||||||
|
scrollX,
|
||||||
|
scrollY,
|
||||||
|
zoom,
|
||||||
|
scrollConstraints,
|
||||||
|
viewModeEnabled: true,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (scrollConstraints) {
|
this.setState({ scrollX, scrollY, zoom });
|
||||||
this.setState({
|
|
||||||
scrollX,
|
|
||||||
scrollY,
|
|
||||||
zoom,
|
|
||||||
scrollConstraints,
|
|
||||||
viewModeEnabled: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.setState({ scrollX, scrollY, zoom });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import type { AppState, NormalizedZoomValue } from "../types";
|
|
||||||
import { constrainScrollState } from "./scrollConstraints";
|
import { constrainScrollState } from "./scrollConstraints";
|
||||||
|
|
||||||
|
import type { AppState, NormalizedZoomValue } from "../types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When zooming out with scroll constraints active, the cursor-anchored zoom may
|
* When zooming out with scroll constraints active, the cursor-anchored zoom may
|
||||||
* produce a scroll position outside the valid bounds, causing a snap-back.
|
* produce a scroll position outside the valid bounds, causing a snap-back.
|
||||||
@@ -30,11 +31,19 @@ export const getConstrainedZoomAnchor = (
|
|||||||
const newScrollY = state.scrollY + appLayerY * factor;
|
const newScrollY = state.scrollY + appLayerY * factor;
|
||||||
|
|
||||||
const constrained = constrainScrollState(
|
const constrained = constrainScrollState(
|
||||||
{ ...state, scrollX: newScrollX, scrollY: newScrollY, zoom: { value: nextZoom } },
|
{
|
||||||
|
...state,
|
||||||
|
scrollX: newScrollX,
|
||||||
|
scrollY: newScrollY,
|
||||||
|
zoom: { value: nextZoom },
|
||||||
|
},
|
||||||
"rigid",
|
"rigid",
|
||||||
);
|
);
|
||||||
|
|
||||||
if (constrained.scrollX === newScrollX && constrained.scrollY === newScrollY) {
|
if (
|
||||||
|
constrained.scrollX === newScrollX &&
|
||||||
|
constrained.scrollY === newScrollY
|
||||||
|
) {
|
||||||
return { viewportX, viewportY };
|
return { viewportX, viewportY };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user