mirror of
https://github.com/excalidraw/excalidraw
synced 2025-07-25 13:58:22 +08:00
Compare commits
85 Commits
mtolmacs/a
...
arnost/scr
Author | SHA1 | Date | |
---|---|---|---|
f6ced89c3c | |||
6eb0596638 | |||
0607003903 | |||
4e2026e47d | |||
67260915cb | |||
c84fad4436 | |||
2e9c8851b3 | |||
19608b712f | |||
3a566a292c | |||
62c800c21a | |||
f9723e2d19 | |||
ffbd4a5dc8 | |||
5dded6112c | |||
84c396aec2 | |||
bc6cc83b1e | |||
baa7b3293a | |||
4208c97b62 | |||
2d0c0afa34 | |||
df26487936 | |||
782772cec5 | |||
39f79927ae | |||
01304aac49 | |||
dff69e9191 | |||
6fc85022ae | |||
1316d884fe | |||
d6710ded04 | |||
78d2a6ecc0 | |||
213134bbca | |||
b5bf346229 | |||
4c62eef7da | |||
82aa1cf19d | |||
9bc874a61e | |||
d5f55aba44 | |||
72de65e482 | |||
0f99e823f4 | |||
3ec09988fa | |||
b40fd65404 | |||
266069ae05 | |||
c33fb846ab | |||
94e9b20951 | |||
186ed43671 | |||
d1e3ea431b | |||
ddb08ce732 | |||
edf54d1543 | |||
b4e80b602d | |||
dd9bde5ee7 | |||
b99bf74c3d | |||
84b19a77d7 | |||
53a88d4c7a | |||
10900f39ee | |||
ebbd72e792 | |||
f8ba862774 | |||
806b1e9705 | |||
b0cdd00c2a | |||
6711735b27 | |||
803e14ada1 | |||
4469c02191 | |||
04e23e1d29 | |||
d24a032dbb | |||
76d3930983 | |||
af6e64ffc2 | |||
4e9039e850 | |||
132750f753 | |||
71eb3023b2 | |||
6d165971fc | |||
9562e4309f | |||
e8e391e465 | |||
92be92071a | |||
71918e57a8 | |||
c0bd9027cb | |||
7336b1c276 | |||
7fb6c23715 | |||
82014fe670 | |||
bc44c3f947 | |||
19ba107041 | |||
381ef93956 | |||
f82363aae9 | |||
485c57fd59 | |||
35b43c14d8 | |||
f7e8056abe | |||
71f7960606 | |||
2998573e79 | |||
209934c90a | |||
a8158691b7 | |||
75f8e904cc |
@ -4,6 +4,7 @@ import {
|
||||
TTDDialogTrigger,
|
||||
CaptureUpdateAction,
|
||||
reconcileElements,
|
||||
getCommonBounds,
|
||||
} from "@excalidraw/excalidraw";
|
||||
import { trackEvent } from "@excalidraw/excalidraw/analytics";
|
||||
import { getDefaultAppState } from "@excalidraw/excalidraw/appState";
|
||||
@ -57,9 +58,21 @@ import {
|
||||
useHandleLibrary,
|
||||
} from "@excalidraw/excalidraw/data/library";
|
||||
|
||||
import { getSelectedElements } from "@excalidraw/element/selection";
|
||||
|
||||
import {
|
||||
decodeConstraints,
|
||||
encodeConstraints,
|
||||
} from "@excalidraw/excalidraw/scene/scrollConstraints";
|
||||
|
||||
import { useApp } from "@excalidraw/excalidraw/components/App";
|
||||
|
||||
import { clamp } from "@excalidraw/math";
|
||||
|
||||
import type { RemoteExcalidrawElement } from "@excalidraw/excalidraw/data/reconcile";
|
||||
import type { RestoredDataState } from "@excalidraw/excalidraw/data/restore";
|
||||
import type {
|
||||
ExcalidrawElement,
|
||||
FileId,
|
||||
NonDeletedExcalidrawElement,
|
||||
OrderedExcalidrawElement,
|
||||
@ -70,8 +83,9 @@ import type {
|
||||
BinaryFiles,
|
||||
ExcalidrawInitialDataState,
|
||||
UIAppState,
|
||||
ScrollConstraints,
|
||||
} from "@excalidraw/excalidraw/types";
|
||||
import type { ResolutionType } from "@excalidraw/common/utility-types";
|
||||
import type { Merge, ResolutionType } from "@excalidraw/common/utility-types";
|
||||
import type { ResolvablePromise } from "@excalidraw/common/utils";
|
||||
|
||||
import CustomStats from "./CustomStats";
|
||||
@ -141,6 +155,274 @@ import type { CollabAPI } from "./collab/Collab";
|
||||
|
||||
polyfill();
|
||||
|
||||
type DebugScrollConstraints = Merge<
|
||||
ScrollConstraints,
|
||||
{ viewportZoomFactor: number; enabled: boolean }
|
||||
>;
|
||||
|
||||
const ConstraintsSettings = ({
|
||||
initialConstraints,
|
||||
excalidrawAPI,
|
||||
}: {
|
||||
initialConstraints: DebugScrollConstraints;
|
||||
excalidrawAPI: ExcalidrawImperativeAPI;
|
||||
}) => {
|
||||
const [constraints, setConstraints] =
|
||||
useState<DebugScrollConstraints>(initialConstraints);
|
||||
|
||||
const app = useApp();
|
||||
const frames = app.scene.getNonDeletedFramesLikes();
|
||||
const [activeFrameId, setActiveFrameId] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
params.set("constraints", encodeConstraints(constraints));
|
||||
history.replaceState(null, "", `?${params.toString()}`);
|
||||
|
||||
constraints.enabled
|
||||
? excalidrawAPI.setScrollConstraints(constraints)
|
||||
: excalidrawAPI.setScrollConstraints(null);
|
||||
}, [constraints, excalidrawAPI]);
|
||||
|
||||
useEffect(() => {
|
||||
const frame = frames.find((frame) => frame.id === activeFrameId);
|
||||
if (frame) {
|
||||
const { x, y, width, height } = frame;
|
||||
setConstraints((s) => ({
|
||||
x: Math.round(x),
|
||||
y: Math.round(y),
|
||||
width: Math.round(width),
|
||||
height: Math.round(height),
|
||||
enabled: s.enabled,
|
||||
viewportZoomFactor: s.viewportZoomFactor,
|
||||
lockZoom: s.lockZoom,
|
||||
}));
|
||||
}
|
||||
}, [activeFrameId, frames]);
|
||||
|
||||
const [selection, setSelection] = useState<ExcalidrawElement[]>([]);
|
||||
useEffect(() => {
|
||||
return excalidrawAPI.onChange((elements, appState) => {
|
||||
setSelection(getSelectedElements(elements, appState));
|
||||
});
|
||||
}, [excalidrawAPI]);
|
||||
|
||||
const parseValue = (
|
||||
value: string,
|
||||
opts?: {
|
||||
min?: number;
|
||||
max?: number;
|
||||
},
|
||||
) => {
|
||||
const { min = -Infinity, max = Infinity } = opts || {};
|
||||
let parsedValue = parseInt(value);
|
||||
if (isNaN(parsedValue)) {
|
||||
parsedValue = 0;
|
||||
}
|
||||
return clamp(parsedValue, min, max);
|
||||
};
|
||||
|
||||
const inputStyle = {
|
||||
width: "4rem",
|
||||
height: "1rem",
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: "fixed",
|
||||
bottom: 10,
|
||||
left: "calc(50%)",
|
||||
transform: "translateX(-50%)",
|
||||
zIndex: 999999,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
flexDirection: "column",
|
||||
gap: "0.5rem",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.6rem",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
enabled:{" "}
|
||||
<input
|
||||
type="checkbox"
|
||||
defaultChecked={!!constraints.enabled}
|
||||
onChange={(e) =>
|
||||
setConstraints((s) => ({ ...s, enabled: e.target.checked }))
|
||||
}
|
||||
/>
|
||||
x:{" "}
|
||||
<input
|
||||
placeholder="x"
|
||||
type="number"
|
||||
step={"10"}
|
||||
value={constraints.x.toString()}
|
||||
onChange={(e) => {
|
||||
setConstraints((s) => ({
|
||||
...s,
|
||||
x: parseValue(e.target.value),
|
||||
}));
|
||||
}}
|
||||
style={inputStyle}
|
||||
/>
|
||||
y:{" "}
|
||||
<input
|
||||
placeholder="y"
|
||||
type="number"
|
||||
step={"10"}
|
||||
value={constraints.y.toString()}
|
||||
onChange={(e) =>
|
||||
setConstraints((s) => ({
|
||||
...s,
|
||||
y: parseValue(e.target.value),
|
||||
}))
|
||||
}
|
||||
style={inputStyle}
|
||||
/>
|
||||
w:{" "}
|
||||
<input
|
||||
placeholder="width"
|
||||
type="number"
|
||||
step={"10"}
|
||||
value={constraints.width.toString()}
|
||||
onChange={(e) =>
|
||||
setConstraints((s) => ({
|
||||
...s,
|
||||
width: parseValue(e.target.value, {
|
||||
min: 200,
|
||||
}),
|
||||
}))
|
||||
}
|
||||
style={inputStyle}
|
||||
/>
|
||||
h:{" "}
|
||||
<input
|
||||
placeholder="height"
|
||||
type="number"
|
||||
step={"10"}
|
||||
value={constraints.height.toString()}
|
||||
onChange={(e) =>
|
||||
setConstraints((s) => ({
|
||||
...s,
|
||||
height: parseValue(e.target.value, {
|
||||
min: 200,
|
||||
}),
|
||||
}))
|
||||
}
|
||||
style={inputStyle}
|
||||
/>
|
||||
zoomFactor:
|
||||
<input
|
||||
placeholder="zoom factor"
|
||||
type="number"
|
||||
min="0.1"
|
||||
max="1"
|
||||
step="0.1"
|
||||
value={constraints.viewportZoomFactor.toString()}
|
||||
onChange={(e) =>
|
||||
setConstraints((s) => ({
|
||||
...s,
|
||||
viewportZoomFactor: parseFloat(e.target.value.toString()) ?? 0.7,
|
||||
}))
|
||||
}
|
||||
style={inputStyle}
|
||||
/>
|
||||
overscrollAllowance:
|
||||
<input
|
||||
placeholder="overscroll allowance"
|
||||
type="number"
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.1"
|
||||
value={constraints.overscrollAllowance?.toString()}
|
||||
onChange={(e) =>
|
||||
setConstraints((s) => ({
|
||||
...s,
|
||||
overscrollAllowance: parseFloat(e.target.value.toString()) ?? 0.5,
|
||||
}))
|
||||
}
|
||||
style={inputStyle}
|
||||
/>
|
||||
lockZoom:{" "}
|
||||
<input
|
||||
type="checkbox"
|
||||
defaultChecked={!!constraints.lockZoom}
|
||||
onChange={(e) =>
|
||||
setConstraints((s) => ({ ...s, lockZoom: e.target.checked }))
|
||||
}
|
||||
value={constraints.lockZoom?.toString()}
|
||||
/>
|
||||
{selection.length > 0 && (
|
||||
<button
|
||||
onClick={() => {
|
||||
const bbox = getCommonBounds(selection);
|
||||
setConstraints((s) => ({
|
||||
...s,
|
||||
x: Math.round(bbox[0]),
|
||||
y: Math.round(bbox[1]),
|
||||
width: Math.round(bbox[2] - bbox[0]),
|
||||
height: Math.round(bbox[3] - bbox[1]),
|
||||
}));
|
||||
}}
|
||||
>
|
||||
use selection
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{frames.length > 0 && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.6rem",
|
||||
flexDirection: "row",
|
||||
}}
|
||||
>
|
||||
<button
|
||||
onClick={() => {
|
||||
const currentIndex = frames.findIndex(
|
||||
(frame) => frame.id === activeFrameId,
|
||||
);
|
||||
|
||||
if (currentIndex === -1) {
|
||||
setActiveFrameId(frames[frames.length - 1].id);
|
||||
} else {
|
||||
const nextIndex =
|
||||
(currentIndex - 1 + frames.length) % frames.length;
|
||||
setActiveFrameId(frames[nextIndex].id);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Prev
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
const currentIndex = frames.findIndex(
|
||||
(frame) => frame.id === activeFrameId,
|
||||
);
|
||||
|
||||
if (currentIndex === -1) {
|
||||
setActiveFrameId(frames[0].id);
|
||||
} else {
|
||||
const nextIndex = (currentIndex + 1) % frames.length;
|
||||
setActiveFrameId(frames[nextIndex].id);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
window.EXCALIDRAW_THROTTLE_RENDER = true;
|
||||
|
||||
declare global {
|
||||
@ -212,10 +494,20 @@ const initializeScene = async (opts: {
|
||||
)
|
||||
> => {
|
||||
const searchParams = new URLSearchParams(window.location.search);
|
||||
const hashParams = new URLSearchParams(window.location.hash.slice(1));
|
||||
const id = searchParams.get("id");
|
||||
const jsonBackendMatch = window.location.hash.match(
|
||||
/^#json=([a-zA-Z0-9_-]+),([a-zA-Z0-9_-]+)$/,
|
||||
);
|
||||
const shareableLink = hashParams.get("json")?.split(",");
|
||||
|
||||
if (shareableLink) {
|
||||
hashParams.delete("json");
|
||||
const hash = `#${decodeURIComponent(hashParams.toString())}`;
|
||||
window.history.replaceState(
|
||||
{},
|
||||
APP_NAME,
|
||||
`${window.location.origin}${hash}`,
|
||||
);
|
||||
}
|
||||
|
||||
const externalUrlMatch = window.location.hash.match(/^#url=(.*)$/);
|
||||
|
||||
const localDataState = importFromLocalStorage();
|
||||
@ -225,7 +517,7 @@ const initializeScene = async (opts: {
|
||||
} = await loadScene(null, null, localDataState);
|
||||
|
||||
let roomLinkData = getCollaborationLinkData(window.location.href);
|
||||
const isExternalScene = !!(id || jsonBackendMatch || roomLinkData);
|
||||
const isExternalScene = !!(id || shareableLink || roomLinkData);
|
||||
if (isExternalScene) {
|
||||
if (
|
||||
// don't prompt if scene is empty
|
||||
@ -235,16 +527,16 @@ const initializeScene = async (opts: {
|
||||
// otherwise, prompt whether user wants to override current scene
|
||||
(await openConfirmModal(shareableLinkConfirmDialog))
|
||||
) {
|
||||
if (jsonBackendMatch) {
|
||||
if (shareableLink) {
|
||||
scene = await loadScene(
|
||||
jsonBackendMatch[1],
|
||||
jsonBackendMatch[2],
|
||||
shareableLink[0],
|
||||
shareableLink[1],
|
||||
localDataState,
|
||||
);
|
||||
}
|
||||
scene.scrollToContent = true;
|
||||
if (!roomLinkData) {
|
||||
window.history.replaceState({}, APP_NAME, window.location.origin);
|
||||
// window.history.replaceState({}, APP_NAME, window.location.origin);
|
||||
}
|
||||
} else {
|
||||
// https://github.com/excalidraw/excalidraw/issues/1919
|
||||
@ -261,7 +553,7 @@ const initializeScene = async (opts: {
|
||||
}
|
||||
|
||||
roomLinkData = null;
|
||||
window.history.replaceState({}, APP_NAME, window.location.origin);
|
||||
// window.history.replaceState({}, APP_NAME, window.location.origin);
|
||||
}
|
||||
} else if (externalUrlMatch) {
|
||||
window.history.replaceState({}, APP_NAME, window.location.origin);
|
||||
@ -322,12 +614,12 @@ const initializeScene = async (opts: {
|
||||
key: roomLinkData.roomKey,
|
||||
};
|
||||
} else if (scene) {
|
||||
return isExternalScene && jsonBackendMatch
|
||||
return isExternalScene && shareableLink
|
||||
? {
|
||||
scene,
|
||||
isExternalScene,
|
||||
id: jsonBackendMatch[1],
|
||||
key: jsonBackendMatch[2],
|
||||
id: shareableLink[0],
|
||||
key: shareableLink[1],
|
||||
}
|
||||
: { scene, isExternalScene: false };
|
||||
}
|
||||
@ -739,6 +1031,32 @@ const ExcalidrawWrapper = () => {
|
||||
[setShareDialogState],
|
||||
);
|
||||
|
||||
const [constraints] = useState<DebugScrollConstraints>(() => {
|
||||
const stored = new URLSearchParams(location.search.slice(1)).get(
|
||||
"constraints",
|
||||
);
|
||||
let storedConstraints = {};
|
||||
if (stored) {
|
||||
try {
|
||||
storedConstraints = decodeConstraints(stored);
|
||||
} catch {
|
||||
console.error("Invalid scroll constraints in URL");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: document.body.clientWidth,
|
||||
height: document.body.clientHeight,
|
||||
lockZoom: false,
|
||||
viewportZoomFactor: 0.7,
|
||||
overscrollAllowance: 0.5,
|
||||
enabled: !isTestEnv(),
|
||||
...storedConstraints,
|
||||
};
|
||||
});
|
||||
|
||||
// browsers generally prevent infinite self-embedding, there are
|
||||
// cases where it still happens, and while we disallow self-embedding
|
||||
// by not whitelisting our own origin, this serves as an additional guard
|
||||
@ -864,6 +1182,7 @@ const ExcalidrawWrapper = () => {
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
scrollConstraints={constraints.enabled ? constraints : undefined}
|
||||
onLinkOpen={(element, event) => {
|
||||
if (element.link && isElementLink(element.link)) {
|
||||
event.preventDefault();
|
||||
@ -871,6 +1190,12 @@ const ExcalidrawWrapper = () => {
|
||||
}
|
||||
}}
|
||||
>
|
||||
{excalidrawAPI && !isTestEnv() && (
|
||||
<ConstraintsSettings
|
||||
excalidrawAPI={excalidrawAPI}
|
||||
initialConstraints={constraints}
|
||||
/>
|
||||
)}
|
||||
<AppMainMenu
|
||||
onCollabDialogOpen={onCollabDialogOpen}
|
||||
isCollaborating={isCollaborating}
|
||||
|
@ -112,6 +112,7 @@ export const YOUTUBE_STATES = {
|
||||
export const ENV = {
|
||||
TEST: "test",
|
||||
DEVELOPMENT: "development",
|
||||
PRODUCTION: "production",
|
||||
};
|
||||
|
||||
export const CLASSES = {
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { average } from "@excalidraw/math";
|
||||
import { average, pointFrom, type GlobalPoint } from "@excalidraw/math";
|
||||
|
||||
import type {
|
||||
ExcalidrawBindableElement,
|
||||
FontFamilyValues,
|
||||
FontString,
|
||||
ExcalidrawElement,
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
import type {
|
||||
@ -738,6 +739,8 @@ export const isTestEnv = () => import.meta.env.MODE === ENV.TEST;
|
||||
|
||||
export const isDevEnv = () => import.meta.env.MODE === ENV.DEVELOPMENT;
|
||||
|
||||
export const isProdEnv = () => import.meta.env.MODE === ENV.PRODUCTION;
|
||||
|
||||
export const isServerEnv = () =>
|
||||
typeof process !== "undefined" && !!process?.env?.NODE_ENV;
|
||||
|
||||
@ -1201,3 +1204,17 @@ export const escapeDoubleQuotes = (str: string) => {
|
||||
|
||||
export const castArray = <T>(value: T | T[]): T[] =>
|
||||
Array.isArray(value) ? value : [value];
|
||||
|
||||
export const elementCenterPoint = (
|
||||
element: ExcalidrawElement,
|
||||
xOffset: number = 0,
|
||||
yOffset: number = 0,
|
||||
) => {
|
||||
const { x, y, width, height } = element;
|
||||
|
||||
const centerXPoint = x + width / 2 + xOffset;
|
||||
|
||||
const centerYPoint = y + height / 2 + yOffset;
|
||||
|
||||
return pointFrom<GlobalPoint>(centerXPoint, centerYPoint);
|
||||
};
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
invariant,
|
||||
isDevEnv,
|
||||
isTestEnv,
|
||||
elementCenterPoint,
|
||||
} from "@excalidraw/common";
|
||||
|
||||
import {
|
||||
@ -904,13 +905,7 @@ export const getHeadingForElbowArrowSnap = (
|
||||
|
||||
if (!distance) {
|
||||
return vectorToHeading(
|
||||
vectorFromPoint(
|
||||
p,
|
||||
pointFrom<GlobalPoint>(
|
||||
bindableElement.x + bindableElement.width / 2,
|
||||
bindableElement.y + bindableElement.height / 2,
|
||||
),
|
||||
),
|
||||
vectorFromPoint(p, elementCenterPoint(bindableElement)),
|
||||
);
|
||||
}
|
||||
|
||||
@ -1040,10 +1035,7 @@ export const avoidRectangularCorner = (
|
||||
element: ExcalidrawBindableElement,
|
||||
p: GlobalPoint,
|
||||
): GlobalPoint => {
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(element);
|
||||
const nonRotatedPoint = pointRotateRads(p, center, -element.angle as Radians);
|
||||
|
||||
if (nonRotatedPoint[0] < element.x && nonRotatedPoint[1] < element.y) {
|
||||
@ -1140,10 +1132,9 @@ export const snapToMid = (
|
||||
tolerance: number = 0.05,
|
||||
): GlobalPoint => {
|
||||
const { x, y, width, height, angle } = element;
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
x + width / 2 - 0.1,
|
||||
y + height / 2 - 0.1,
|
||||
);
|
||||
|
||||
const center = elementCenterPoint(element, -0.1, -0.1);
|
||||
|
||||
const nonRotated = pointRotateRads(p, center, -angle as Radians);
|
||||
|
||||
// snap-to-center point is adaptive to element size, but we don't want to go
|
||||
@ -1228,10 +1219,7 @@ const updateBoundPoint = (
|
||||
startOrEnd === "startBinding" ? "start" : "end",
|
||||
elementsMap,
|
||||
).fixedPoint;
|
||||
const globalMidPoint = pointFrom<GlobalPoint>(
|
||||
bindableElement.x + bindableElement.width / 2,
|
||||
bindableElement.y + bindableElement.height / 2,
|
||||
);
|
||||
const globalMidPoint = elementCenterPoint(bindableElement);
|
||||
const global = pointFrom<GlobalPoint>(
|
||||
bindableElement.x + fixedPoint[0] * bindableElement.width,
|
||||
bindableElement.y + fixedPoint[1] * bindableElement.height,
|
||||
@ -1275,10 +1263,7 @@ const updateBoundPoint = (
|
||||
elementsMap,
|
||||
);
|
||||
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
bindableElement.x + bindableElement.width / 2,
|
||||
bindableElement.y + bindableElement.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(bindableElement);
|
||||
const interceptorLength =
|
||||
pointDistance(adjacentPoint, edgePointAbsolute) +
|
||||
pointDistance(adjacentPoint, center) +
|
||||
@ -1771,10 +1756,7 @@ const determineFocusDistance = (
|
||||
// Another point on the line, in absolute coordinates (closer to element)
|
||||
b: GlobalPoint,
|
||||
): number => {
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(element);
|
||||
|
||||
if (pointsEqual(a, b)) {
|
||||
return 0;
|
||||
@ -1904,10 +1886,7 @@ const determineFocusPoint = (
|
||||
focus: number,
|
||||
adjacentPoint: GlobalPoint,
|
||||
): GlobalPoint => {
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(element);
|
||||
|
||||
if (focus === 0) {
|
||||
return center;
|
||||
@ -2338,10 +2317,7 @@ export const getGlobalFixedPointForBindableElement = (
|
||||
element.x + element.width * fixedX,
|
||||
element.y + element.height * fixedY,
|
||||
),
|
||||
pointFrom<GlobalPoint>(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
),
|
||||
elementCenterPoint(element),
|
||||
element.angle,
|
||||
);
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { isTransparent } from "@excalidraw/common";
|
||||
import { isTransparent, elementCenterPoint } from "@excalidraw/common";
|
||||
import {
|
||||
curveIntersectLineSegment,
|
||||
isPointWithinBounds,
|
||||
@ -16,7 +16,7 @@ import {
|
||||
} from "@excalidraw/math/ellipse";
|
||||
|
||||
import { isPointInShape, isPointOnShape } from "@excalidraw/utils/collision";
|
||||
import { getPolygonShape } from "@excalidraw/utils/shape";
|
||||
import { type GeometricShape, getPolygonShape } from "@excalidraw/utils/shape";
|
||||
|
||||
import type {
|
||||
GlobalPoint,
|
||||
@ -26,8 +26,6 @@ import type {
|
||||
Radians,
|
||||
} from "@excalidraw/math";
|
||||
|
||||
import type { GeometricShape } from "@excalidraw/utils/shape";
|
||||
|
||||
import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
|
||||
|
||||
import { getBoundTextShape, isPathALoop } from "./shapes";
|
||||
@ -191,10 +189,7 @@ const intersectRectanguloidWithLineSegment = (
|
||||
l: LineSegment<GlobalPoint>,
|
||||
offset: number = 0,
|
||||
): GlobalPoint[] => {
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(element);
|
||||
// To emulate a rotated rectangle we rotate the point in the inverse angle
|
||||
// instead. It's all the same distance-wise.
|
||||
const rotatedA = pointRotateRads<GlobalPoint>(
|
||||
@ -253,10 +248,7 @@ const intersectDiamondWithLineSegment = (
|
||||
l: LineSegment<GlobalPoint>,
|
||||
offset: number = 0,
|
||||
): GlobalPoint[] => {
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(element);
|
||||
|
||||
// Rotate the point to the inverse direction to simulate the rotated diamond
|
||||
// points. It's all the same distance-wise.
|
||||
@ -304,10 +296,7 @@ const intersectEllipseWithLineSegment = (
|
||||
l: LineSegment<GlobalPoint>,
|
||||
offset: number = 0,
|
||||
): GlobalPoint[] => {
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(element);
|
||||
|
||||
const rotatedA = pointRotateRads(l[0], center, -element.angle as Radians);
|
||||
const rotatedB = pointRotateRads(l[1], center, -element.angle as Radians);
|
||||
|
@ -14,6 +14,8 @@ import {
|
||||
} from "@excalidraw/math";
|
||||
import { type Point } from "points-on-curve";
|
||||
|
||||
import { elementCenterPoint } from "@excalidraw/common";
|
||||
|
||||
import {
|
||||
getElementAbsoluteCoords,
|
||||
getResizedElementAbsoluteCoords,
|
||||
@ -61,7 +63,7 @@ export const cropElement = (
|
||||
|
||||
const rotatedPointer = pointRotateRads(
|
||||
pointFrom(pointerX, pointerY),
|
||||
pointFrom(element.x + element.width / 2, element.y + element.height / 2),
|
||||
elementCenterPoint(element),
|
||||
-element.angle as Radians,
|
||||
);
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
import {
|
||||
curvePointDistance,
|
||||
distanceToLineSegment,
|
||||
pointFrom,
|
||||
pointRotateRads,
|
||||
} from "@excalidraw/math";
|
||||
|
||||
import { ellipse, ellipseDistanceFromPoint } from "@excalidraw/math/ellipse";
|
||||
|
||||
import { elementCenterPoint } from "@excalidraw/common";
|
||||
|
||||
import type { GlobalPoint, Radians } from "@excalidraw/math";
|
||||
|
||||
import {
|
||||
@ -53,10 +54,7 @@ const distanceToRectanguloidElement = (
|
||||
element: ExcalidrawRectanguloidElement,
|
||||
p: GlobalPoint,
|
||||
) => {
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(element);
|
||||
// To emulate a rotated rectangle we rotate the point in the inverse angle
|
||||
// instead. It's all the same distance-wise.
|
||||
const rotatedPoint = pointRotateRads(p, center, -element.angle as Radians);
|
||||
@ -84,10 +82,7 @@ const distanceToDiamondElement = (
|
||||
element: ExcalidrawDiamondElement,
|
||||
p: GlobalPoint,
|
||||
): number => {
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(element);
|
||||
|
||||
// Rotate the point to the inverse direction to simulate the rotated diamond
|
||||
// points. It's all the same distance-wise.
|
||||
@ -115,10 +110,7 @@ const distanceToEllipseElement = (
|
||||
element: ExcalidrawEllipseElement,
|
||||
p: GlobalPoint,
|
||||
): number => {
|
||||
const center = pointFrom(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(element);
|
||||
return ellipseDistanceFromPoint(
|
||||
// Instead of rotating the ellipse, rotate the point to the inverse angle
|
||||
pointRotateRads(p, center, -element.angle as Radians),
|
||||
|
@ -4,6 +4,7 @@ import {
|
||||
LINE_CONFIRM_THRESHOLD,
|
||||
ROUNDNESS,
|
||||
invariant,
|
||||
elementCenterPoint,
|
||||
} from "@excalidraw/common";
|
||||
import {
|
||||
isPoint,
|
||||
@ -297,7 +298,7 @@ export const aabbForElement = (
|
||||
midY: element.y + element.height / 2,
|
||||
};
|
||||
|
||||
const center = pointFrom(bbox.midX, bbox.midY);
|
||||
const center = elementCenterPoint(element);
|
||||
const [topLeftX, topLeftY] = pointRotateRads(
|
||||
pointFrom(bbox.minX, bbox.minY),
|
||||
center,
|
||||
|
@ -6,6 +6,8 @@ import {
|
||||
TEXT_ALIGN,
|
||||
VERTICAL_ALIGN,
|
||||
getFontString,
|
||||
isProdEnv,
|
||||
invariant,
|
||||
} from "@excalidraw/common";
|
||||
|
||||
import type { AppState } from "@excalidraw/excalidraw/types";
|
||||
@ -26,6 +28,8 @@ import {
|
||||
isTextElement,
|
||||
} from "./typeChecks";
|
||||
|
||||
import type { Radians } from "../../math/src";
|
||||
|
||||
import type { MaybeTransformHandleType } from "./transformHandles";
|
||||
import type {
|
||||
ElementsMap,
|
||||
@ -44,13 +48,25 @@ export const redrawTextBoundingBox = (
|
||||
informMutation = true,
|
||||
) => {
|
||||
let maxWidth = undefined;
|
||||
|
||||
if (!isProdEnv()) {
|
||||
invariant(
|
||||
!container || !isArrowElement(container) || textElement.angle === 0,
|
||||
"text element angle must be 0 if bound to arrow container",
|
||||
);
|
||||
}
|
||||
|
||||
const boundTextUpdates = {
|
||||
x: textElement.x,
|
||||
y: textElement.y,
|
||||
text: textElement.text,
|
||||
width: textElement.width,
|
||||
height: textElement.height,
|
||||
angle: container?.angle ?? textElement.angle,
|
||||
angle: (container
|
||||
? isArrowElement(container)
|
||||
? 0
|
||||
: container.angle
|
||||
: textElement.angle) as Radians,
|
||||
};
|
||||
|
||||
boundTextUpdates.text = textElement.text;
|
||||
@ -335,7 +351,10 @@ export const getTextElementAngle = (
|
||||
textElement: ExcalidrawTextElement,
|
||||
container: ExcalidrawTextContainer | null,
|
||||
) => {
|
||||
if (!container || isArrowElement(container)) {
|
||||
if (isArrowElement(container)) {
|
||||
return 0;
|
||||
}
|
||||
if (!container) {
|
||||
return textElement.angle;
|
||||
}
|
||||
return container.angle;
|
||||
|
@ -10,6 +10,8 @@ import {
|
||||
type GlobalPoint,
|
||||
} from "@excalidraw/math";
|
||||
|
||||
import { elementCenterPoint } from "@excalidraw/common";
|
||||
|
||||
import type { Curve, LineSegment } from "@excalidraw/math";
|
||||
|
||||
import { getCornerRadius } from "./shapes";
|
||||
@ -68,10 +70,7 @@ export function deconstructRectanguloidElement(
|
||||
return [sides, []];
|
||||
}
|
||||
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(element);
|
||||
|
||||
const r = rectangle(
|
||||
pointFrom(element.x, element.y),
|
||||
@ -254,10 +253,7 @@ export function deconstructDiamondElement(
|
||||
return [[topRight, bottomRight, bottomLeft, topLeft], []];
|
||||
}
|
||||
|
||||
const center = pointFrom<GlobalPoint>(
|
||||
element.x + element.width / 2,
|
||||
element.y + element.height / 2,
|
||||
);
|
||||
const center = elementCenterPoint(element);
|
||||
|
||||
const [top, right, bottom, left]: GlobalPoint[] = [
|
||||
pointFrom(element.x + topX, element.y + topY),
|
||||
|
@ -21,6 +21,7 @@ import {
|
||||
|
||||
import {
|
||||
hasBoundTextElement,
|
||||
isArrowElement,
|
||||
isTextBindableContainer,
|
||||
isTextElement,
|
||||
isUsingAdaptiveRadius,
|
||||
@ -46,6 +47,8 @@ import { CaptureUpdateAction } from "../store";
|
||||
|
||||
import { register } from "./register";
|
||||
|
||||
import type { Radians } from "../../math/src";
|
||||
|
||||
import type { AppState } from "../types";
|
||||
|
||||
export const actionUnbindText = register({
|
||||
@ -155,6 +158,7 @@ export const actionBindText = register({
|
||||
verticalAlign: VERTICAL_ALIGN.MIDDLE,
|
||||
textAlign: TEXT_ALIGN.CENTER,
|
||||
autoResize: true,
|
||||
angle: (isArrowElement(container) ? 0 : container?.angle ?? 0) as Radians,
|
||||
});
|
||||
mutateElement(container, {
|
||||
boundElements: (container.boundElements || []).concat({
|
||||
|
@ -39,6 +39,7 @@ import {
|
||||
ZoomResetIcon,
|
||||
} from "../components/icons";
|
||||
import { setCursor } from "../cursor";
|
||||
import { constrainScrollState } from "../scene/scrollConstraints";
|
||||
|
||||
import { t } from "../i18n";
|
||||
import { getNormalizedZoom } from "../scene";
|
||||
@ -136,7 +137,7 @@ export const actionZoomIn = register({
|
||||
trackEvent: { category: "canvas" },
|
||||
perform: (_elements, appState, _, app) => {
|
||||
return {
|
||||
appState: {
|
||||
appState: constrainScrollState({
|
||||
...appState,
|
||||
...getStateForZoom(
|
||||
{
|
||||
@ -147,7 +148,7 @@ export const actionZoomIn = register({
|
||||
appState,
|
||||
),
|
||||
userToFollow: null,
|
||||
},
|
||||
}),
|
||||
captureUpdate: CaptureUpdateAction.EVENTUALLY,
|
||||
};
|
||||
},
|
||||
@ -177,7 +178,7 @@ export const actionZoomOut = register({
|
||||
trackEvent: { category: "canvas" },
|
||||
perform: (_elements, appState, _, app) => {
|
||||
return {
|
||||
appState: {
|
||||
appState: constrainScrollState({
|
||||
...appState,
|
||||
...getStateForZoom(
|
||||
{
|
||||
@ -188,7 +189,7 @@ export const actionZoomOut = register({
|
||||
appState,
|
||||
),
|
||||
userToFollow: null,
|
||||
},
|
||||
}),
|
||||
captureUpdate: CaptureUpdateAction.EVENTUALLY,
|
||||
};
|
||||
},
|
||||
|
@ -191,11 +191,7 @@ export class AnimatedTrail implements Trail {
|
||||
});
|
||||
|
||||
const stroke = this.trailAnimation
|
||||
? _stroke.slice(
|
||||
// slicing from 6th point to get rid of the initial notch type of thing
|
||||
Math.min(_stroke.length, 6),
|
||||
_stroke.length / 2,
|
||||
)
|
||||
? _stroke.slice(0, _stroke.length / 2)
|
||||
: _stroke;
|
||||
|
||||
return getSvgPathFromStroke(stroke, true);
|
||||
|
@ -20,7 +20,7 @@ const defaultExportScale = EXPORT_SCALES.includes(devicePixelRatio)
|
||||
|
||||
export const getDefaultAppState = (): Omit<
|
||||
AppState,
|
||||
"offsetTop" | "offsetLeft" | "width" | "height"
|
||||
"offsetTop" | "offsetLeft" | "width" | "height" | "scrollConstraints"
|
||||
> => {
|
||||
return {
|
||||
showWelcomeScreen: false,
|
||||
@ -243,6 +243,7 @@ const APP_STATE_STORAGE_CONF = (<
|
||||
objectsSnapModeEnabled: { browser: true, export: false, server: false },
|
||||
userToFollow: { browser: false, export: false, server: false },
|
||||
followedBy: { browser: false, export: false, server: false },
|
||||
scrollConstraints: { browser: false, export: false, server: false },
|
||||
isCropping: { browser: false, export: false, server: false },
|
||||
croppingElementId: { browser: false, export: false, server: false },
|
||||
searchMatches: { browser: false, export: false, server: false },
|
||||
|
@ -464,6 +464,12 @@ import { isMaybeMermaidDefinition } from "../mermaid";
|
||||
|
||||
import { LassoTrail } from "../lasso";
|
||||
|
||||
import {
|
||||
constrainScrollState,
|
||||
calculateConstrainedScrollCenter,
|
||||
areCanvasTranslatesClose,
|
||||
} from "../scene/scrollConstraints";
|
||||
|
||||
import { activeConfirmDialogAtom } from "./ActiveConfirmDialog";
|
||||
import BraveMeasureTextError from "./BraveMeasureTextError";
|
||||
import { ContextMenu, CONTEXT_MENU_SEPARATOR } from "./ContextMenu";
|
||||
@ -513,6 +519,8 @@ import type {
|
||||
FrameNameBoundsCache,
|
||||
SidebarName,
|
||||
SidebarTabName,
|
||||
ScrollConstraints,
|
||||
AnimateTranslateCanvasValues,
|
||||
KeyboardModifiersObject,
|
||||
CollaboratorPointer,
|
||||
ToolType,
|
||||
@ -561,6 +569,7 @@ const ExcalidrawAppStateContext = React.createContext<AppState>({
|
||||
height: 0,
|
||||
offsetLeft: 0,
|
||||
offsetTop: 0,
|
||||
scrollConstraints: null,
|
||||
});
|
||||
ExcalidrawAppStateContext.displayName = "ExcalidrawAppStateContext";
|
||||
|
||||
@ -598,6 +607,8 @@ let isDraggingScrollBar: boolean = false;
|
||||
let currentScrollBars: ScrollBars = { horizontal: null, vertical: null };
|
||||
let touchTimeout = 0;
|
||||
let invalidateContextMenu = false;
|
||||
let scrollConstraintsAnimationTimeout: ReturnType<typeof setTimeout> | null =
|
||||
null;
|
||||
|
||||
/**
|
||||
* Map of youtube embed video states
|
||||
@ -741,7 +752,9 @@ class App extends React.Component<AppProps, AppState> {
|
||||
objectsSnapModeEnabled = false,
|
||||
theme = defaultAppState.theme,
|
||||
name = `${t("labels.untitled")}-${getDateTime()}`,
|
||||
scrollConstraints,
|
||||
} = props;
|
||||
|
||||
this.state = {
|
||||
...defaultAppState,
|
||||
theme,
|
||||
@ -754,6 +767,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
name,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
scrollConstraints: scrollConstraints ?? null,
|
||||
};
|
||||
|
||||
this.id = nanoid();
|
||||
@ -800,6 +814,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
resetCursor: this.resetCursor,
|
||||
updateFrameRendering: this.updateFrameRendering,
|
||||
toggleSidebar: this.toggleSidebar,
|
||||
setScrollConstraints: this.setScrollConstraints,
|
||||
onChange: (cb) => this.onChangeEmitter.on(cb),
|
||||
onPointerDown: (cb) => this.onPointerDownEmitter.on(cb),
|
||||
onPointerUp: (cb) => this.onPointerUpEmitter.on(cb),
|
||||
@ -2393,7 +2408,12 @@ class App extends React.Component<AppProps, AppState> {
|
||||
isLoading: false,
|
||||
toast: this.state.toast,
|
||||
};
|
||||
if (initialData?.scrollToContent) {
|
||||
if (this.props.scrollConstraints) {
|
||||
scene.appState = {
|
||||
...scene.appState,
|
||||
...calculateConstrainedScrollCenter(this.state, scene.appState),
|
||||
};
|
||||
} else if (initialData?.scrollToContent) {
|
||||
scene.appState = {
|
||||
...scene.appState,
|
||||
...calculateScrollCenter(scene.elements, {
|
||||
@ -2402,6 +2422,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
height: this.state.height,
|
||||
offsetTop: this.state.offsetTop,
|
||||
offsetLeft: this.state.offsetLeft,
|
||||
scrollConstraints: this.state.scrollConstraints,
|
||||
}),
|
||||
};
|
||||
}
|
||||
@ -2615,7 +2636,11 @@ class App extends React.Component<AppProps, AppState> {
|
||||
if (!supportsResizeObserver) {
|
||||
this.refreshEditorBreakpoints();
|
||||
}
|
||||
this.setState({});
|
||||
if (this.state.scrollConstraints) {
|
||||
this.setState((state) => constrainScrollState(state));
|
||||
} else {
|
||||
this.setState({});
|
||||
}
|
||||
});
|
||||
|
||||
/** generally invoked only if fullscreen was invoked programmatically */
|
||||
@ -2947,6 +2972,33 @@ class App extends React.Component<AppProps, AppState> {
|
||||
this.props.onChange?.(elements, this.state, this.files);
|
||||
this.onChangeEmitter.trigger(elements, this.state, this.files);
|
||||
}
|
||||
|
||||
if (this.state.scrollConstraints?.animateOnNextUpdate) {
|
||||
const newState = constrainScrollState(this.state, "rigid");
|
||||
const fromValues = {
|
||||
scrollX: this.state.scrollX,
|
||||
scrollY: this.state.scrollY,
|
||||
zoom: this.state.zoom.value,
|
||||
};
|
||||
const toValues = {
|
||||
scrollX: newState.scrollX,
|
||||
scrollY: newState.scrollY,
|
||||
zoom: newState.zoom.value,
|
||||
};
|
||||
|
||||
if (areCanvasTranslatesClose(fromValues, toValues)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (scrollConstraintsAnimationTimeout) {
|
||||
clearTimeout(scrollConstraintsAnimationTimeout);
|
||||
}
|
||||
|
||||
scrollConstraintsAnimationTimeout = setTimeout(() => {
|
||||
this.cancelInProgressAnimation?.();
|
||||
this.animateToConstrainedArea(fromValues, toValues);
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
private renderInteractiveSceneCallback = ({
|
||||
@ -3693,8 +3745,8 @@ class App extends React.Component<AppProps, AppState> {
|
||||
*/
|
||||
value: number,
|
||||
) => {
|
||||
this.setState({
|
||||
...getStateForZoom(
|
||||
this.setState(
|
||||
getStateForZoom(
|
||||
{
|
||||
viewportX: this.state.width / 2 + this.state.offsetLeft,
|
||||
viewportY: this.state.height / 2 + this.state.offsetTop,
|
||||
@ -3702,7 +3754,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
},
|
||||
this.state,
|
||||
),
|
||||
});
|
||||
);
|
||||
};
|
||||
|
||||
private cancelInProgressAnimation: (() => void) | null = null;
|
||||
@ -3802,32 +3854,18 @@ class App extends React.Component<AppProps, AppState> {
|
||||
// when animating, we use RequestAnimationFrame to prevent the animation
|
||||
// from slowing down other processes
|
||||
if (opts?.animate) {
|
||||
const origScrollX = this.state.scrollX;
|
||||
const origScrollY = this.state.scrollY;
|
||||
const origZoom = this.state.zoom.value;
|
||||
const fromValues = {
|
||||
scrollX: this.state.scrollX,
|
||||
scrollY: this.state.scrollY,
|
||||
zoom: this.state.zoom.value,
|
||||
};
|
||||
|
||||
const cancel = easeToValuesRAF({
|
||||
fromValues: {
|
||||
scrollX: origScrollX,
|
||||
scrollY: origScrollY,
|
||||
zoom: origZoom,
|
||||
},
|
||||
toValues: { scrollX, scrollY, zoom: zoom.value },
|
||||
interpolateValue: (from, to, progress, key) => {
|
||||
// for zoom, use different easing
|
||||
if (key === "zoom") {
|
||||
return from * Math.pow(to / from, easeOut(progress));
|
||||
}
|
||||
// handle using default
|
||||
return undefined;
|
||||
},
|
||||
onStep: ({ scrollX, scrollY, zoom }) => {
|
||||
this.setState({
|
||||
scrollX,
|
||||
scrollY,
|
||||
zoom: { value: zoom },
|
||||
});
|
||||
},
|
||||
const toValues = { scrollX, scrollY, zoom: zoom.value };
|
||||
|
||||
this.animateTranslateCanvas({
|
||||
fromValues,
|
||||
toValues,
|
||||
duration: opts?.duration ?? 500,
|
||||
onStart: () => {
|
||||
this.setState({ shouldCacheIgnoreZoom: true });
|
||||
},
|
||||
@ -3837,13 +3875,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
onCancel: () => {
|
||||
this.setState({ shouldCacheIgnoreZoom: false });
|
||||
},
|
||||
duration: opts?.duration ?? 500,
|
||||
});
|
||||
|
||||
this.cancelInProgressAnimation = () => {
|
||||
cancel();
|
||||
this.cancelInProgressAnimation = null;
|
||||
};
|
||||
} else {
|
||||
this.setState({ scrollX, scrollY, zoom });
|
||||
}
|
||||
@ -3857,11 +3889,158 @@ class App extends React.Component<AppProps, AppState> {
|
||||
|
||||
/** use when changing scrollX/scrollY/zoom based on user interaction */
|
||||
private translateCanvas: React.Component<any, AppState>["setState"] = (
|
||||
state,
|
||||
stateUpdate,
|
||||
) => {
|
||||
this.cancelInProgressAnimation?.();
|
||||
this.maybeUnfollowRemoteUser();
|
||||
this.setState(state);
|
||||
|
||||
if (scrollConstraintsAnimationTimeout) {
|
||||
clearTimeout(scrollConstraintsAnimationTimeout);
|
||||
}
|
||||
|
||||
const partialNewState =
|
||||
typeof stateUpdate === "function"
|
||||
? (
|
||||
stateUpdate as (
|
||||
prevState: Readonly<AppState>,
|
||||
props: Readonly<AppProps>,
|
||||
) => AppState
|
||||
)(this.state, this.props)
|
||||
: stateUpdate;
|
||||
|
||||
const newState: AppState = {
|
||||
...this.state,
|
||||
...partialNewState,
|
||||
...(this.state.scrollConstraints && {
|
||||
// manually reset if setState in onCancel wasn't committed yet
|
||||
shouldCacheIgnoreZoom: false,
|
||||
}),
|
||||
};
|
||||
|
||||
// RULE: cannot go below the minimum zoom level if zoom lock is enabled
|
||||
const constrainedState =
|
||||
newState.scrollConstraints && newState.scrollConstraints.lockZoom
|
||||
? constrainScrollState(newState, "elastic")
|
||||
: newState;
|
||||
if (constrainedState.zoom.value > newState.zoom.value) {
|
||||
newState.zoom = constrainedState.zoom;
|
||||
newState.scrollX = constrainedState.scrollX;
|
||||
newState.scrollY = constrainedState.scrollY;
|
||||
|
||||
this.debounceConstrainScrollState(newState);
|
||||
return;
|
||||
}
|
||||
|
||||
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) => {
|
||||
const newState = constrainScrollState(state, "rigid");
|
||||
|
||||
const fromValues = {
|
||||
scrollX: this.state.scrollX,
|
||||
scrollY: this.state.scrollY,
|
||||
zoom: this.state.zoom.value,
|
||||
};
|
||||
const toValues = {
|
||||
scrollX: newState.scrollX,
|
||||
scrollY: newState.scrollY,
|
||||
zoom: newState.zoom.value,
|
||||
};
|
||||
|
||||
if (areCanvasTranslatesClose(fromValues, toValues)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.cancelInProgressAnimation?.();
|
||||
this.animateToConstrainedArea(fromValues, toValues);
|
||||
}, 200);
|
||||
|
||||
private animateToConstrainedArea = (
|
||||
fromValues: AnimateTranslateCanvasValues,
|
||||
toValues: AnimateTranslateCanvasValues,
|
||||
) => {
|
||||
const cleanUp = () => {
|
||||
this.setState((state) => ({
|
||||
shouldCacheIgnoreZoom: false,
|
||||
scrollConstraints: {
|
||||
...state.scrollConstraints!,
|
||||
animateOnNextUpdate: false,
|
||||
},
|
||||
}));
|
||||
};
|
||||
|
||||
this.animateTranslateCanvas({
|
||||
fromValues,
|
||||
toValues,
|
||||
duration: 200,
|
||||
onStart: () => {
|
||||
this.setState((state) => {
|
||||
return {
|
||||
shouldCacheIgnoreZoom: true,
|
||||
scrollConstraints: {
|
||||
...state.scrollConstraints!,
|
||||
animateOnNextUpdate: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
onEnd: cleanUp,
|
||||
onCancel: cleanUp,
|
||||
});
|
||||
};
|
||||
|
||||
private animateTranslateCanvas = ({
|
||||
fromValues,
|
||||
toValues,
|
||||
duration,
|
||||
onStart,
|
||||
onEnd,
|
||||
onCancel,
|
||||
}: {
|
||||
fromValues: AnimateTranslateCanvasValues;
|
||||
toValues: AnimateTranslateCanvasValues;
|
||||
duration: number;
|
||||
onStart: () => void;
|
||||
onEnd: () => void;
|
||||
onCancel: () => void;
|
||||
}) => {
|
||||
const cancel = easeToValuesRAF({
|
||||
fromValues,
|
||||
toValues,
|
||||
interpolateValue: (from, to, progress, key) => {
|
||||
// for zoom, use different easing
|
||||
if (key === "zoom") {
|
||||
return from * Math.pow(to / from, easeOut(progress));
|
||||
}
|
||||
// handle using default
|
||||
return undefined;
|
||||
},
|
||||
onStep: ({ scrollX, scrollY, zoom }) => {
|
||||
this.setState({
|
||||
scrollX,
|
||||
scrollY,
|
||||
zoom: { value: zoom },
|
||||
});
|
||||
},
|
||||
onStart,
|
||||
onEnd,
|
||||
onCancel,
|
||||
duration,
|
||||
});
|
||||
|
||||
this.cancelInProgressAnimation = () => {
|
||||
cancel();
|
||||
this.cancelInProgressAnimation = null;
|
||||
};
|
||||
};
|
||||
|
||||
setToast = (
|
||||
@ -4891,16 +5070,22 @@ class App extends React.Component<AppProps, AppState> {
|
||||
|
||||
const initialScale = gesture.initialScale;
|
||||
if (initialScale) {
|
||||
this.setState((state) => ({
|
||||
...getStateForZoom(
|
||||
this.setState((state) =>
|
||||
constrainScrollState(
|
||||
{
|
||||
viewportX: this.lastViewportPosition.x,
|
||||
viewportY: this.lastViewportPosition.y,
|
||||
nextZoom: getNormalizedZoom(initialScale * event.scale),
|
||||
...state,
|
||||
...getStateForZoom(
|
||||
{
|
||||
viewportX: this.lastViewportPosition.x,
|
||||
viewportY: this.lastViewportPosition.y,
|
||||
nextZoom: getNormalizedZoom(initialScale * event.scale),
|
||||
},
|
||||
state,
|
||||
),
|
||||
},
|
||||
state,
|
||||
"loose",
|
||||
),
|
||||
}));
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@ -5352,37 +5537,37 @@ class App extends React.Component<AppProps, AppState> {
|
||||
y: sceneY,
|
||||
});
|
||||
|
||||
const element = existingTextElement
|
||||
? existingTextElement
|
||||
: newTextElement({
|
||||
x: parentCenterPosition
|
||||
? parentCenterPosition.elementCenterX
|
||||
: sceneX,
|
||||
y: parentCenterPosition
|
||||
? parentCenterPosition.elementCenterY
|
||||
: sceneY,
|
||||
strokeColor: this.state.currentItemStrokeColor,
|
||||
backgroundColor: this.state.currentItemBackgroundColor,
|
||||
fillStyle: this.state.currentItemFillStyle,
|
||||
strokeWidth: this.state.currentItemStrokeWidth,
|
||||
strokeStyle: this.state.currentItemStrokeStyle,
|
||||
roughness: this.state.currentItemRoughness,
|
||||
opacity: this.state.currentItemOpacity,
|
||||
text: "",
|
||||
fontSize,
|
||||
fontFamily,
|
||||
textAlign: parentCenterPosition
|
||||
? "center"
|
||||
: this.state.currentItemTextAlign,
|
||||
verticalAlign: parentCenterPosition
|
||||
? VERTICAL_ALIGN.MIDDLE
|
||||
: DEFAULT_VERTICAL_ALIGN,
|
||||
containerId: shouldBindToContainer ? container?.id : undefined,
|
||||
groupIds: container?.groupIds ?? [],
|
||||
lineHeight,
|
||||
angle: container?.angle ?? (0 as Radians),
|
||||
frameId: topLayerFrame ? topLayerFrame.id : null,
|
||||
});
|
||||
const element =
|
||||
existingTextElement ||
|
||||
newTextElement({
|
||||
x: parentCenterPosition ? parentCenterPosition.elementCenterX : sceneX,
|
||||
y: parentCenterPosition ? parentCenterPosition.elementCenterY : sceneY,
|
||||
strokeColor: this.state.currentItemStrokeColor,
|
||||
backgroundColor: this.state.currentItemBackgroundColor,
|
||||
fillStyle: this.state.currentItemFillStyle,
|
||||
strokeWidth: this.state.currentItemStrokeWidth,
|
||||
strokeStyle: this.state.currentItemStrokeStyle,
|
||||
roughness: this.state.currentItemRoughness,
|
||||
opacity: this.state.currentItemOpacity,
|
||||
text: "",
|
||||
fontSize,
|
||||
fontFamily,
|
||||
textAlign: parentCenterPosition
|
||||
? "center"
|
||||
: this.state.currentItemTextAlign,
|
||||
verticalAlign: parentCenterPosition
|
||||
? VERTICAL_ALIGN.MIDDLE
|
||||
: DEFAULT_VERTICAL_ALIGN,
|
||||
containerId: shouldBindToContainer ? container?.id : undefined,
|
||||
groupIds: container?.groupIds ?? [],
|
||||
lineHeight,
|
||||
angle: container
|
||||
? isArrowElement(container)
|
||||
? (0 as Radians)
|
||||
: container.angle
|
||||
: (0 as Radians),
|
||||
frameId: topLayerFrame ? topLayerFrame.id : null,
|
||||
});
|
||||
|
||||
if (!existingTextElement && shouldBindToContainer && container) {
|
||||
mutateElement(container, {
|
||||
@ -11189,6 +11374,51 @@ class App extends React.Component<AppProps, AppState> {
|
||||
await setLanguage(currentLang);
|
||||
this.setAppState({});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the scroll constraints of the application state.
|
||||
*
|
||||
* @param scrollConstraints - The new scroll constraints.
|
||||
*/
|
||||
public setScrollConstraints = (
|
||||
scrollConstraints: ScrollConstraints | null,
|
||||
) => {
|
||||
if (scrollConstraints) {
|
||||
this.setState(
|
||||
{
|
||||
scrollConstraints,
|
||||
viewModeEnabled: true,
|
||||
},
|
||||
() => {
|
||||
const newState = constrainScrollState(
|
||||
{
|
||||
...this.state,
|
||||
scrollConstraints,
|
||||
},
|
||||
"rigid",
|
||||
);
|
||||
|
||||
this.animateToConstrainedArea(
|
||||
{
|
||||
scrollX: this.state.scrollX,
|
||||
scrollY: this.state.scrollY,
|
||||
zoom: this.state.zoom.value,
|
||||
},
|
||||
{
|
||||
scrollX: newState.scrollX,
|
||||
scrollY: newState.scrollY,
|
||||
zoom: newState.zoom.value,
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
this.setState({
|
||||
scrollConstraints: null,
|
||||
viewModeEnabled: false,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -553,7 +553,7 @@ const LayerUI = ({
|
||||
showExitZenModeBtn={showExitZenModeBtn}
|
||||
renderWelcomeScreen={renderWelcomeScreen}
|
||||
/>
|
||||
{appState.scrolledOutside && (
|
||||
{appState.scrolledOutside && !appState.scrollConstraints && (
|
||||
<button
|
||||
type="button"
|
||||
className="scroll-back-to-content"
|
||||
|
@ -195,7 +195,8 @@ export const MobileMenu = ({
|
||||
{renderAppToolbar()}
|
||||
{appState.scrolledOutside &&
|
||||
!appState.openMenu &&
|
||||
!appState.openSidebar && (
|
||||
!appState.openSidebar &&
|
||||
!appState.scrollConstraints && (
|
||||
<button
|
||||
type="button"
|
||||
className="scroll-back-to-content"
|
||||
|
@ -78,7 +78,7 @@ import type { ImportedDataState, LegacyAppState } from "./types";
|
||||
|
||||
type RestoredAppState = Omit<
|
||||
AppState,
|
||||
"offsetTop" | "offsetLeft" | "width" | "height"
|
||||
"offsetTop" | "offsetLeft" | "width" | "height" | "scrollConstraints"
|
||||
>;
|
||||
|
||||
export const AllowedExcalidrawActiveTools: Record<
|
||||
@ -439,7 +439,7 @@ const repairContainerElement = (
|
||||
// if defined, lest boundElements is stale
|
||||
!boundElement.containerId
|
||||
) {
|
||||
(boundElement as Mutable<ExcalidrawTextElement>).containerId =
|
||||
(boundElement as Mutable<typeof boundElement>).containerId =
|
||||
container.id;
|
||||
}
|
||||
}
|
||||
@ -464,6 +464,10 @@ const repairBoundElement = (
|
||||
? elementsMap.get(boundElement.containerId)
|
||||
: null;
|
||||
|
||||
(boundElement as Mutable<typeof boundElement>).angle = (
|
||||
isArrowElement(container) ? 0 : container?.angle ?? 0
|
||||
) as Radians;
|
||||
|
||||
if (!container) {
|
||||
boundElement.containerId = null;
|
||||
return;
|
||||
|
@ -67,6 +67,7 @@ const canvas = exportToCanvas(
|
||||
offsetLeft: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
scrollConstraints: null,
|
||||
},
|
||||
{}, // files
|
||||
{
|
||||
|
@ -49,6 +49,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
|
||||
onScrollChange,
|
||||
onDuplicate,
|
||||
children,
|
||||
scrollConstraints,
|
||||
validateEmbeddable,
|
||||
renderEmbeddable,
|
||||
aiEnabled,
|
||||
@ -119,7 +120,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
|
||||
onPointerUpdate={onPointerUpdate}
|
||||
renderTopRightUI={renderTopRightUI}
|
||||
langCode={langCode}
|
||||
viewModeEnabled={viewModeEnabled}
|
||||
viewModeEnabled={viewModeEnabled ?? !!scrollConstraints}
|
||||
zenModeEnabled={zenModeEnabled}
|
||||
gridModeEnabled={gridModeEnabled}
|
||||
libraryReturnUrl={libraryReturnUrl}
|
||||
@ -138,6 +139,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
|
||||
onPointerDown={onPointerDown}
|
||||
onPointerUp={onPointerUp}
|
||||
onScrollChange={onScrollChange}
|
||||
scrollConstraints={scrollConstraints}
|
||||
onDuplicate={onDuplicate}
|
||||
validateEmbeddable={validateEmbeddable}
|
||||
renderEmbeddable={renderEmbeddable}
|
||||
|
@ -2,9 +2,9 @@ import { simplify } from "points-on-curve";
|
||||
|
||||
import {
|
||||
polygonFromPoints,
|
||||
polygonIncludesPoint,
|
||||
lineSegment,
|
||||
lineSegmentIntersectionPoints,
|
||||
polygonIncludesPointNonZero,
|
||||
} from "@excalidraw/math";
|
||||
|
||||
import type { GlobalPoint, LineSegment } from "@excalidraw/math/types";
|
||||
@ -35,8 +35,6 @@ export const getLassoSelectedElementIds = (input: {
|
||||
if (simplifyDistance) {
|
||||
path = simplify(lassoPath, simplifyDistance) as GlobalPoint[];
|
||||
}
|
||||
// close the path to form a polygon for enclosure check
|
||||
const closedPath = polygonFromPoints(path);
|
||||
// as the path might not enclose a shape anymore, clear before checking
|
||||
enclosedElements.clear();
|
||||
for (const element of elements) {
|
||||
@ -44,15 +42,11 @@ export const getLassoSelectedElementIds = (input: {
|
||||
!intersectedElements.has(element.id) &&
|
||||
!enclosedElements.has(element.id)
|
||||
) {
|
||||
const enclosed = enclosureTest(closedPath, element, elementsSegments);
|
||||
const enclosed = enclosureTest(path, element, elementsSegments);
|
||||
if (enclosed) {
|
||||
enclosedElements.add(element.id);
|
||||
} else {
|
||||
const intersects = intersectionTest(
|
||||
closedPath,
|
||||
element,
|
||||
elementsSegments,
|
||||
);
|
||||
const intersects = intersectionTest(path, element, elementsSegments);
|
||||
if (intersects) {
|
||||
intersectedElements.add(element.id);
|
||||
}
|
||||
@ -79,7 +73,9 @@ const enclosureTest = (
|
||||
}
|
||||
|
||||
return segments.some((segment) => {
|
||||
return segment.some((point) => polygonIncludesPoint(point, lassoPolygon));
|
||||
return segment.some((point) =>
|
||||
polygonIncludesPointNonZero(point, lassoPolygon),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
|
552
packages/excalidraw/scene/scrollConstraints.ts
Normal file
552
packages/excalidraw/scene/scrollConstraints.ts
Normal file
@ -0,0 +1,552 @@
|
||||
import { isShallowEqual } from "@excalidraw/common";
|
||||
|
||||
import { clamp } from "@excalidraw/math";
|
||||
|
||||
import { getNormalizedZoom } from "./normalize";
|
||||
|
||||
import type {
|
||||
AnimateTranslateCanvasValues,
|
||||
AppState,
|
||||
ScrollConstraints,
|
||||
} from "../types";
|
||||
|
||||
// Constants for viewport zoom factor and overscroll allowance
|
||||
const MIN_VIEWPORT_ZOOM_FACTOR = 0.1;
|
||||
const MAX_VIEWPORT_ZOOM_FACTOR = 1;
|
||||
const DEFAULT_VIEWPORT_ZOOM_FACTOR = 0.2;
|
||||
const DEFAULT_OVERSCROLL_ALLOWANCE = 0.2;
|
||||
|
||||
// Memoization variable to cache constraints for performance optimization
|
||||
let memoizedValues: {
|
||||
previousState: Pick<
|
||||
AppState,
|
||||
"zoom" | "width" | "height" | "scrollConstraints"
|
||||
>;
|
||||
constraints: ReturnType<typeof calculateConstraints>;
|
||||
allowOverscroll: boolean;
|
||||
} | null = null;
|
||||
|
||||
type CanvasTranslate = Pick<AppState, "scrollX" | "scrollY" | "zoom">;
|
||||
|
||||
/**
|
||||
* Calculates the zoom levels necessary to fit the constrained scrollable area within the viewport on the X and Y axes.
|
||||
*
|
||||
* The function considers the dimensions of the scrollable area, the dimensions of the viewport, the viewport zoom factor,
|
||||
* and whether the zoom should be locked. It then calculates the necessary zoom levels for the X and Y axes separately.
|
||||
* If the zoom should be locked, it calculates the maximum zoom level that fits the scrollable area within the viewport,
|
||||
* factoring in the viewport zoom factor. If the zoom should not be locked, the maximum zoom level is set to null.
|
||||
*
|
||||
* @param scrollConstraints - The constraints of the scrollable area including width, height, and position.
|
||||
* @param width - The width of the viewport.
|
||||
* @param height - The height of the viewport.
|
||||
* @returns An object containing the calculated zoom levels for the X and Y axes, and the initial zoom level.
|
||||
*/
|
||||
const calculateZoomLevel = (
|
||||
scrollConstraints: ScrollConstraints,
|
||||
width: AppState["width"],
|
||||
height: AppState["height"],
|
||||
) => {
|
||||
const viewportZoomFactor = scrollConstraints.viewportZoomFactor
|
||||
? clamp(
|
||||
scrollConstraints.viewportZoomFactor,
|
||||
MIN_VIEWPORT_ZOOM_FACTOR,
|
||||
MAX_VIEWPORT_ZOOM_FACTOR,
|
||||
)
|
||||
: DEFAULT_VIEWPORT_ZOOM_FACTOR;
|
||||
|
||||
const scrollableWidth = scrollConstraints.width;
|
||||
const scrollableHeight = scrollConstraints.height;
|
||||
const zoomLevelX = width / scrollableWidth;
|
||||
const zoomLevelY = height / scrollableHeight;
|
||||
const initialZoomLevel = getNormalizedZoom(
|
||||
Math.min(zoomLevelX, zoomLevelY) * viewportZoomFactor,
|
||||
);
|
||||
return { zoomLevelX, zoomLevelY, initialZoomLevel };
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the effective zoom level based on the scroll constraints and current zoom.
|
||||
*
|
||||
* @param params - Object containing scrollConstraints, width, height, and zoom.
|
||||
* @returns An object with the effective zoom level, initial zoom level, and zoom levels for X and Y axes.
|
||||
*/
|
||||
const calculateZoom = ({
|
||||
scrollConstraints,
|
||||
width,
|
||||
height,
|
||||
zoom,
|
||||
}: {
|
||||
scrollConstraints: ScrollConstraints;
|
||||
width: AppState["width"];
|
||||
height: AppState["height"];
|
||||
zoom: AppState["zoom"];
|
||||
}) => {
|
||||
const { zoomLevelX, zoomLevelY, initialZoomLevel } = calculateZoomLevel(
|
||||
scrollConstraints,
|
||||
width,
|
||||
height,
|
||||
);
|
||||
const effectiveZoom = scrollConstraints.lockZoom
|
||||
? Math.max(initialZoomLevel, zoom.value)
|
||||
: zoom.value;
|
||||
return {
|
||||
effectiveZoom: getNormalizedZoom(effectiveZoom),
|
||||
initialZoomLevel,
|
||||
zoomLevelX,
|
||||
zoomLevelY,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the scroll bounds (min and max scroll values) based on the scroll constraints and zoom level.
|
||||
*
|
||||
* @param params - Object containing scrollConstraints, width, height, effectiveZoom, zoomLevelX, zoomLevelY, and allowOverscroll.
|
||||
* @returns An object with min and max scroll values for X and Y axes.
|
||||
*/
|
||||
const calculateScrollBounds = ({
|
||||
scrollConstraints,
|
||||
width,
|
||||
height,
|
||||
effectiveZoom,
|
||||
zoomLevelX,
|
||||
zoomLevelY,
|
||||
allowOverscroll,
|
||||
}: {
|
||||
scrollConstraints: ScrollConstraints;
|
||||
width: AppState["width"];
|
||||
height: AppState["height"];
|
||||
effectiveZoom: number;
|
||||
zoomLevelX: number;
|
||||
zoomLevelY: number;
|
||||
allowOverscroll: boolean;
|
||||
}) => {
|
||||
const overscrollAllowance =
|
||||
scrollConstraints.overscrollAllowance ?? DEFAULT_OVERSCROLL_ALLOWANCE;
|
||||
const validatedOverscroll = clamp(overscrollAllowance, 0, 1);
|
||||
|
||||
const calculateCenter = (zoom: number) => {
|
||||
const centerX =
|
||||
scrollConstraints.x + (scrollConstraints.width - width / zoom) / -2;
|
||||
const centerY =
|
||||
scrollConstraints.y + (scrollConstraints.height - height / zoom) / -2;
|
||||
return { centerX, centerY };
|
||||
};
|
||||
|
||||
const { centerX, centerY } = calculateCenter(effectiveZoom);
|
||||
|
||||
const overscrollValue = Math.min(
|
||||
validatedOverscroll * scrollConstraints.width,
|
||||
validatedOverscroll * scrollConstraints.height,
|
||||
);
|
||||
|
||||
const fitsX = effectiveZoom <= zoomLevelX;
|
||||
const fitsY = effectiveZoom <= zoomLevelY;
|
||||
|
||||
const getScrollRange = (
|
||||
axis: "x" | "y",
|
||||
fits: boolean,
|
||||
constraint: ScrollConstraints,
|
||||
viewportSize: number,
|
||||
zoom: number,
|
||||
overscroll: number,
|
||||
) => {
|
||||
const { pos, size } =
|
||||
axis === "x"
|
||||
? { pos: constraint.x, size: constraint.width }
|
||||
: { pos: constraint.y, size: constraint.height };
|
||||
const center = axis === "x" ? centerX : centerY;
|
||||
if (allowOverscroll) {
|
||||
return fits
|
||||
? { min: center - overscroll, max: center + overscroll }
|
||||
: {
|
||||
min: pos - size + viewportSize / zoom - overscroll,
|
||||
max: pos + overscroll,
|
||||
};
|
||||
}
|
||||
return fits
|
||||
? { min: center, max: center }
|
||||
: { min: pos - size + viewportSize / zoom, max: pos };
|
||||
};
|
||||
|
||||
const xRange = getScrollRange(
|
||||
"x",
|
||||
fitsX,
|
||||
scrollConstraints,
|
||||
width,
|
||||
effectiveZoom,
|
||||
overscrollValue,
|
||||
);
|
||||
const yRange = getScrollRange(
|
||||
"y",
|
||||
fitsY,
|
||||
scrollConstraints,
|
||||
height,
|
||||
effectiveZoom,
|
||||
overscrollValue,
|
||||
);
|
||||
|
||||
return {
|
||||
minScrollX: xRange.min,
|
||||
maxScrollX: xRange.max,
|
||||
minScrollY: yRange.min,
|
||||
maxScrollY: yRange.max,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the scroll constraints including min and max scroll values and the effective zoom level.
|
||||
*
|
||||
* @param params - Object containing scrollConstraints, width, height, zoom, and allowOverscroll.
|
||||
* @returns An object with min and max scroll values, effective zoom, and initial zoom level.
|
||||
*/
|
||||
const calculateConstraints = ({
|
||||
scrollConstraints,
|
||||
width,
|
||||
height,
|
||||
zoom,
|
||||
allowOverscroll,
|
||||
}: {
|
||||
scrollConstraints: ScrollConstraints;
|
||||
width: AppState["width"];
|
||||
height: AppState["height"];
|
||||
zoom: AppState["zoom"];
|
||||
allowOverscroll: boolean;
|
||||
}) => {
|
||||
const { effectiveZoom, initialZoomLevel, zoomLevelX, zoomLevelY } =
|
||||
calculateZoom({ scrollConstraints, width, height, zoom });
|
||||
const scrollBounds = calculateScrollBounds({
|
||||
scrollConstraints,
|
||||
width,
|
||||
height,
|
||||
effectiveZoom,
|
||||
zoomLevelX,
|
||||
zoomLevelY,
|
||||
allowOverscroll,
|
||||
});
|
||||
|
||||
return {
|
||||
...scrollBounds,
|
||||
effectiveZoom: { value: effectiveZoom },
|
||||
initialZoomLevel,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Constrains the scroll values within the provided min and max bounds.
|
||||
*
|
||||
* @param params - Object containing scrollX, scrollY, minScrollX, maxScrollX, minScrollY, maxScrollY, and constrainedZoom.
|
||||
* @returns An object with constrained scrollX, scrollY, and zoom.
|
||||
*/
|
||||
const constrainScrollValues = ({
|
||||
scrollX,
|
||||
scrollY,
|
||||
minScrollX,
|
||||
maxScrollX,
|
||||
minScrollY,
|
||||
maxScrollY,
|
||||
constrainedZoom,
|
||||
}: {
|
||||
scrollX: number;
|
||||
scrollY: number;
|
||||
minScrollX: number;
|
||||
maxScrollX: number;
|
||||
minScrollY: number;
|
||||
maxScrollY: number;
|
||||
constrainedZoom: AppState["zoom"];
|
||||
}): CanvasTranslate => {
|
||||
const constrainedScrollX = clamp(scrollX, minScrollX, maxScrollX);
|
||||
const constrainedScrollY = clamp(scrollY, minScrollY, maxScrollY);
|
||||
return {
|
||||
scrollX: constrainedScrollX,
|
||||
scrollY: constrainedScrollY,
|
||||
zoom: constrainedZoom,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Inverts the scroll constraints to align with the state scrollX and scrollY values, which are inverted.
|
||||
* This is a temporary fix and should be removed once issue #5965 is resolved.
|
||||
*
|
||||
* @param originalScrollConstraints - The original scroll constraints.
|
||||
* @returns The aligned scroll constraints with inverted x and y coordinates.
|
||||
*/
|
||||
const alignScrollConstraints = (
|
||||
originalScrollConstraints: ScrollConstraints,
|
||||
): ScrollConstraints => {
|
||||
return {
|
||||
...originalScrollConstraints,
|
||||
x: originalScrollConstraints.x * -1,
|
||||
y: originalScrollConstraints.y * -1,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether the current viewport is outside the constrained area.
|
||||
*
|
||||
* @param state - The application state.
|
||||
* @returns True if the viewport is outside the constrained area, false otherwise.
|
||||
*/
|
||||
const isViewportOutsideOfConstrainedArea = (state: AppState): boolean => {
|
||||
if (!state.scrollConstraints) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const {
|
||||
scrollX,
|
||||
scrollY,
|
||||
width,
|
||||
height,
|
||||
scrollConstraints: inverseScrollConstraints,
|
||||
zoom,
|
||||
} = state;
|
||||
|
||||
const scrollConstraints = alignScrollConstraints(inverseScrollConstraints);
|
||||
|
||||
const adjustedWidth = width / zoom.value;
|
||||
const adjustedHeight = height / zoom.value;
|
||||
|
||||
return (
|
||||
scrollX > scrollConstraints.x ||
|
||||
scrollX - adjustedWidth < scrollConstraints.x - scrollConstraints.width ||
|
||||
scrollY > scrollConstraints.y ||
|
||||
scrollY - adjustedHeight < scrollConstraints.y - scrollConstraints.height
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the scroll center coordinates and the optimal zoom level to fit the constrained scrollable area within the viewport.
|
||||
*
|
||||
* @param state - The application state.
|
||||
* @param scroll - Object containing current scrollX and scrollY.
|
||||
* @returns An object with the calculated scrollX, scrollY, and zoom.
|
||||
*/
|
||||
export const calculateConstrainedScrollCenter = (
|
||||
state: AppState,
|
||||
{ scrollX, scrollY }: Pick<AppState, "scrollX" | "scrollY">,
|
||||
): CanvasTranslate => {
|
||||
const { width, height, scrollConstraints } = state;
|
||||
if (!scrollConstraints) {
|
||||
return { scrollX, scrollY, zoom: state.zoom };
|
||||
}
|
||||
|
||||
const adjustedConstraints = alignScrollConstraints(scrollConstraints);
|
||||
const zoomLevels = calculateZoomLevel(adjustedConstraints, width, height);
|
||||
const initialZoom = { value: zoomLevels.initialZoomLevel };
|
||||
const constraints = calculateConstraints({
|
||||
scrollConstraints: adjustedConstraints,
|
||||
width,
|
||||
height,
|
||||
zoom: initialZoom,
|
||||
allowOverscroll: false,
|
||||
});
|
||||
|
||||
return {
|
||||
scrollX: constraints.minScrollX,
|
||||
scrollY: constraints.minScrollY,
|
||||
zoom: constraints.effectiveZoom,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Encodes scroll constraints into a compact string.
|
||||
*
|
||||
* @param constraints - The scroll constraints to encode.
|
||||
* @returns A compact encoded string representing the scroll constraints.
|
||||
*/
|
||||
export const encodeConstraints = (constraints: ScrollConstraints): string => {
|
||||
const payload = {
|
||||
x: constraints.x,
|
||||
y: constraints.y,
|
||||
w: constraints.width,
|
||||
h: constraints.height,
|
||||
a: !!constraints.animateOnNextUpdate,
|
||||
l: !!constraints.lockZoom,
|
||||
v: constraints.viewportZoomFactor ?? 1,
|
||||
oa: constraints.overscrollAllowance ?? DEFAULT_OVERSCROLL_ALLOWANCE,
|
||||
};
|
||||
const serialized = JSON.stringify(payload);
|
||||
return encodeURIComponent(window.btoa(serialized).replace(/=+/, ""));
|
||||
};
|
||||
|
||||
/**
|
||||
* Decodes a compact string back into scroll constraints.
|
||||
*
|
||||
* @param encoded - The encoded string representing the scroll constraints.
|
||||
* @returns The decoded scroll constraints object.
|
||||
*/
|
||||
export const decodeConstraints = (encoded: string): ScrollConstraints => {
|
||||
try {
|
||||
const decodedStr = window.atob(decodeURIComponent(encoded));
|
||||
const parsed = JSON.parse(decodedStr) as {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
a: boolean;
|
||||
l: boolean;
|
||||
v: number;
|
||||
oa: number;
|
||||
};
|
||||
return {
|
||||
x: parsed.x || 0,
|
||||
y: parsed.y || 0,
|
||||
width: parsed.w || 0,
|
||||
height: parsed.h || 0,
|
||||
lockZoom: parsed.l || false,
|
||||
viewportZoomFactor: parsed.v || 1,
|
||||
animateOnNextUpdate: parsed.a || false,
|
||||
overscrollAllowance: parsed.oa || DEFAULT_OVERSCROLL_ALLOWANCE,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
animateOnNextUpdate: false,
|
||||
lockZoom: false,
|
||||
viewportZoomFactor: 1,
|
||||
overscrollAllowance: DEFAULT_OVERSCROLL_ALLOWANCE,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
type Options = { allowOverscroll: boolean; disableAnimation: boolean };
|
||||
const DEFAULT_OPTION: Options = {
|
||||
allowOverscroll: true,
|
||||
disableAnimation: false,
|
||||
};
|
||||
|
||||
/**
|
||||
* Constrains the AppState scroll values within the defined scroll constraints.
|
||||
*
|
||||
* constraintMode can be "elastic", "rigid", or "loose":
|
||||
* - "elastic": snaps to constraints but allows overscroll
|
||||
* - "rigid": snaps to constraints without overscroll
|
||||
* - "loose": allows overscroll and disables animation/snapping to constraints
|
||||
*
|
||||
* @param state - The original AppState.
|
||||
* @param options - Options for allowing overscroll and disabling animation.
|
||||
* @returns A new AppState object with constrained scroll values.
|
||||
*/
|
||||
export const constrainScrollState = (
|
||||
state: AppState,
|
||||
constraintMode: "elastic" | "rigid" | "loose" = "elastic",
|
||||
): AppState => {
|
||||
if (!state.scrollConstraints) {
|
||||
return state;
|
||||
}
|
||||
const {
|
||||
scrollX,
|
||||
scrollY,
|
||||
width,
|
||||
height,
|
||||
scrollConstraints: inverseScrollConstraints,
|
||||
zoom,
|
||||
} = state;
|
||||
|
||||
let allowOverscroll: boolean;
|
||||
let disableAnimation: boolean;
|
||||
|
||||
switch (constraintMode) {
|
||||
case "elastic":
|
||||
({ allowOverscroll, disableAnimation } = DEFAULT_OPTION);
|
||||
break;
|
||||
case "rigid":
|
||||
allowOverscroll = false;
|
||||
disableAnimation = false;
|
||||
break;
|
||||
case "loose":
|
||||
allowOverscroll = true;
|
||||
disableAnimation = true;
|
||||
break;
|
||||
default:
|
||||
({ allowOverscroll, disableAnimation } = DEFAULT_OPTION);
|
||||
break;
|
||||
}
|
||||
|
||||
const scrollConstraints = alignScrollConstraints(inverseScrollConstraints);
|
||||
|
||||
const canUseMemoizedValues =
|
||||
memoizedValues &&
|
||||
memoizedValues.previousState.scrollConstraints &&
|
||||
memoizedValues.allowOverscroll === allowOverscroll &&
|
||||
isShallowEqual(
|
||||
state.scrollConstraints,
|
||||
memoizedValues.previousState.scrollConstraints,
|
||||
) &&
|
||||
isShallowEqual(
|
||||
{ zoom: zoom.value, width, height },
|
||||
{
|
||||
zoom: memoizedValues.previousState.zoom.value,
|
||||
width: memoizedValues.previousState.width,
|
||||
height: memoizedValues.previousState.height,
|
||||
},
|
||||
);
|
||||
|
||||
const constraints = canUseMemoizedValues
|
||||
? memoizedValues!.constraints
|
||||
: calculateConstraints({
|
||||
scrollConstraints,
|
||||
width,
|
||||
height,
|
||||
zoom,
|
||||
allowOverscroll,
|
||||
});
|
||||
|
||||
if (!canUseMemoizedValues) {
|
||||
memoizedValues = {
|
||||
previousState: {
|
||||
zoom: state.zoom,
|
||||
width: state.width,
|
||||
height: state.height,
|
||||
scrollConstraints: state.scrollConstraints,
|
||||
},
|
||||
constraints,
|
||||
allowOverscroll,
|
||||
};
|
||||
}
|
||||
|
||||
const constrainedValues =
|
||||
zoom.value >= constraints.effectiveZoom.value
|
||||
? constrainScrollValues({
|
||||
scrollX,
|
||||
scrollY,
|
||||
minScrollX: constraints.minScrollX,
|
||||
maxScrollX: constraints.maxScrollX,
|
||||
minScrollY: constraints.minScrollY,
|
||||
maxScrollY: constraints.maxScrollY,
|
||||
constrainedZoom: constraints.effectiveZoom,
|
||||
})
|
||||
: calculateConstrainedScrollCenter(state, { scrollX, scrollY });
|
||||
|
||||
return {
|
||||
...state,
|
||||
scrollConstraints: {
|
||||
...state.scrollConstraints,
|
||||
animateOnNextUpdate: disableAnimation
|
||||
? false
|
||||
: isViewportOutsideOfConstrainedArea(state),
|
||||
},
|
||||
...constrainedValues,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if two canvas translate values are close within a threshold.
|
||||
*
|
||||
* @param from - First set of canvas translate values.
|
||||
* @param to - Second set of canvas translate values.
|
||||
* @returns True if the values are close, false otherwise.
|
||||
*/
|
||||
export const areCanvasTranslatesClose = (
|
||||
from: AnimateTranslateCanvasValues,
|
||||
to: AnimateTranslateCanvasValues,
|
||||
): boolean => {
|
||||
const threshold = 0.1;
|
||||
return (
|
||||
Math.abs(from.scrollX - to.scrollX) < threshold &&
|
||||
Math.abs(from.scrollY - to.scrollY) < threshold &&
|
||||
Math.abs(from.zoom - to.zoom) < threshold
|
||||
);
|
||||
};
|
@ -139,6 +139,11 @@ export type ScrollBars = {
|
||||
} | null;
|
||||
};
|
||||
|
||||
export type ConstrainedScrollValues = Pick<
|
||||
AppState,
|
||||
"scrollX" | "scrollY" | "zoom"
|
||||
> | null;
|
||||
|
||||
export type ElementShape = Drawable | Drawable[] | null;
|
||||
|
||||
export type ElementShapes = {
|
||||
|
@ -958,6 +958,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -1165,6 +1166,7 @@ exports[`contextMenu element > selecting 'Add to library' in context menu adds e
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -1385,6 +1387,7 @@ exports[`contextMenu element > selecting 'Bring forward' in context menu brings
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -1720,6 +1723,7 @@ exports[`contextMenu element > selecting 'Bring to front' in context menu brings
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -2055,6 +2059,7 @@ exports[`contextMenu element > selecting 'Copy styles' in context menu copies st
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -2275,6 +2280,7 @@ exports[`contextMenu element > selecting 'Delete' in context menu deletes elemen
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -2519,6 +2525,7 @@ exports[`contextMenu element > selecting 'Duplicate' in context menu duplicates
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -2826,6 +2833,7 @@ exports[`contextMenu element > selecting 'Group selection' in context menu group
|
||||
"id1": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -3197,6 +3205,7 @@ exports[`contextMenu element > selecting 'Paste styles' in context menu pastes s
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -3676,6 +3685,7 @@ exports[`contextMenu element > selecting 'Send backward' in context menu sends e
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -4003,6 +4013,7 @@ exports[`contextMenu element > selecting 'Send to back' in context menu sends el
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -4332,6 +4343,7 @@ exports[`contextMenu element > selecting 'Ungroup selection' in context menu ung
|
||||
"id1": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -5613,6 +5625,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -6835,6 +6848,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -7771,6 +7785,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -8775,6 +8790,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -9767,6 +9783,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
|
@ -82,6 +82,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
||||
"id172": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -682,6 +683,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
||||
"id167": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -1191,6 +1193,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -1563,6 +1566,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -1936,6 +1940,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -2204,6 +2209,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -2647,6 +2653,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -2950,6 +2957,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -3238,6 +3246,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -3536,6 +3545,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -3826,6 +3836,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -4065,6 +4076,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -4328,6 +4340,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -4605,6 +4618,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -4840,6 +4854,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -5075,6 +5090,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -5308,6 +5324,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -5541,6 +5558,7 @@ exports[`history > multiplayer undo/redo > conflicts in frames and their childre
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -5803,6 +5821,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
||||
"id116": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -6138,6 +6157,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
||||
"id103": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -6567,6 +6587,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
||||
"id106": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -6950,6 +6971,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -7270,6 +7292,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -7572,6 +7595,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -7805,6 +7829,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -8164,6 +8189,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -8526,6 +8552,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
||||
"id134": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -8931,6 +8958,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -9222,6 +9250,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -9491,6 +9520,7 @@ exports[`history > multiplayer undo/redo > should not override remote changes on
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -9759,6 +9789,7 @@ exports[`history > multiplayer undo/redo > should not override remote changes on
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -9997,6 +10028,7 @@ exports[`history > multiplayer undo/redo > should override remotely added groups
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -10299,6 +10331,7 @@ exports[`history > multiplayer undo/redo > should override remotely added points
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -10643,6 +10676,7 @@ exports[`history > multiplayer undo/redo > should redistribute deltas when eleme
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -10885,6 +10919,7 @@ exports[`history > multiplayer undo/redo > should redraw arrows on undo > [end o
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -11335,6 +11370,7 @@ exports[`history > multiplayer undo/redo > should update history entries after r
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -11593,6 +11629,7 @@ exports[`history > singleplayer undo/redo > remounting undo/redo buttons should
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -11836,6 +11873,7 @@ exports[`history > singleplayer undo/redo > should clear the redo stack on eleme
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -12081,6 +12119,7 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -12489,6 +12528,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on s
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": -50,
|
||||
"scrollY": -50,
|
||||
"searchMatches": [],
|
||||
@ -12737,6 +12777,7 @@ exports[`history > singleplayer undo/redo > should disable undo/redo buttons whe
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -12982,6 +13023,7 @@ exports[`history > singleplayer undo/redo > should end up with no history entry
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -13229,6 +13271,7 @@ exports[`history > singleplayer undo/redo > should iterate through the history w
|
||||
"id15": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -13478,6 +13521,7 @@ exports[`history > singleplayer undo/redo > should not clear the redo stack on s
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -13817,6 +13861,7 @@ exports[`history > singleplayer undo/redo > should not collapse when applying co
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -13990,6 +14035,7 @@ exports[`history > singleplayer undo/redo > should not end up with history entry
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -14285,6 +14331,7 @@ exports[`history > singleplayer undo/redo > should not end up with history entry
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -14555,6 +14602,7 @@ exports[`history > singleplayer undo/redo > should not override appstate changes
|
||||
"id11": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -14835,6 +14883,7 @@ exports[`history > singleplayer undo/redo > should support appstate name or view
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -14999,6 +15048,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
|
||||
"id56": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -15697,6 +15747,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
|
||||
"id50": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -16317,6 +16368,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
|
||||
"id62": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -16935,6 +16987,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -17648,6 +17701,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
|
||||
"id75": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -18396,6 +18450,7 @@ exports[`history > singleplayer undo/redo > should support changes in elements'
|
||||
"id45": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -18874,6 +18929,7 @@ exports[`history > singleplayer undo/redo > should support duplication of groups
|
||||
"id36": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -19400,6 +19456,7 @@ exports[`history > singleplayer undo/redo > should support element creation, del
|
||||
"id23": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
@ -19860,6 +19917,7 @@ exports[`history > singleplayer undo/redo > should support linear element creati
|
||||
"id27": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"searchMatches": [],
|
||||
|
@ -85,6 +85,7 @@ exports[`given element A and group of elements B and given both are selected whe
|
||||
"id2": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -501,6 +502,7 @@ exports[`given element A and group of elements B and given both are selected whe
|
||||
"id2": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -904,6 +906,7 @@ exports[`regression tests > Cmd/Ctrl-click exclusively select element under poin
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -1450,6 +1453,7 @@ exports[`regression tests > Drags selected element when hitting only bounding bo
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -1657,6 +1661,7 @@ exports[`regression tests > adjusts z order when grouping > [end of test] appSta
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -2033,6 +2038,7 @@ exports[`regression tests > alt-drag duplicates an element > [end of test] appSt
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -2270,6 +2276,7 @@ exports[`regression tests > arrow keys > [end of test] appState 1`] = `
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -2453,6 +2460,7 @@ exports[`regression tests > can drag element that covers another element, while
|
||||
"id2": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -2772,6 +2780,7 @@ exports[`regression tests > change the properties of a shape > [end of test] app
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -3021,6 +3030,7 @@ exports[`regression tests > click on an element and drag it > [dragged] appState
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -3265,6 +3275,7 @@ exports[`regression tests > click on an element and drag it > [end of test] appS
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -3496,6 +3507,7 @@ exports[`regression tests > click to select a shape > [end of test] appState 1`]
|
||||
"id1": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -3753,6 +3765,7 @@ exports[`regression tests > click-drag to select a group > [end of test] appStat
|
||||
"id2": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -4063,6 +4076,7 @@ exports[`regression tests > deleting last but one element in editing group shoul
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -4489,6 +4503,7 @@ exports[`regression tests > deselects group of selected elements on pointer down
|
||||
"id1": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -4773,6 +4788,7 @@ exports[`regression tests > deselects group of selected elements on pointer up w
|
||||
"id1": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -5026,6 +5042,7 @@ exports[`regression tests > deselects selected element on pointer down when poin
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -5237,6 +5254,7 @@ exports[`regression tests > deselects selected element, on pointer up, when clic
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -5435,6 +5453,7 @@ exports[`regression tests > double click to edit a group > [end of test] appStat
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -5821,6 +5840,7 @@ exports[`regression tests > drags selected elements from point inside common bou
|
||||
"id1": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -6109,6 +6129,7 @@ exports[`regression tests > draw every type of shape > [end of test] appState 1`
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -6921,6 +6942,7 @@ exports[`regression tests > given a group of selected elements with an element t
|
||||
"id2": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -7251,6 +7273,7 @@ exports[`regression tests > given a selected element A and a not selected elemen
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -7528,6 +7551,7 @@ exports[`regression tests > given selected element A with lower z-index than uns
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -7763,6 +7787,7 @@ exports[`regression tests > given selected element A with lower z-index than uns
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -7999,6 +8024,7 @@ exports[`regression tests > key 2 selects rectangle tool > [end of test] appStat
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -8180,6 +8206,7 @@ exports[`regression tests > key 3 selects diamond tool > [end of test] appState
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -8361,6 +8388,7 @@ exports[`regression tests > key 4 selects ellipse tool > [end of test] appState
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -8542,6 +8570,7 @@ exports[`regression tests > key 5 selects arrow tool > [end of test] appState 1`
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -8766,6 +8795,7 @@ exports[`regression tests > key 6 selects line tool > [end of test] appState 1`]
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -8989,6 +9019,7 @@ exports[`regression tests > key 7 selects freedraw tool > [end of test] appState
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -9184,6 +9215,7 @@ exports[`regression tests > key a selects arrow tool > [end of test] appState 1`
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -9408,6 +9440,7 @@ exports[`regression tests > key d selects diamond tool > [end of test] appState
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -9589,6 +9622,7 @@ exports[`regression tests > key l selects line tool > [end of test] appState 1`]
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -9812,6 +9846,7 @@ exports[`regression tests > key o selects ellipse tool > [end of test] appState
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -9993,6 +10028,7 @@ exports[`regression tests > key p selects freedraw tool > [end of test] appState
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -10188,6 +10224,7 @@ exports[`regression tests > key r selects rectangle tool > [end of test] appStat
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -10373,6 +10410,7 @@ exports[`regression tests > make a group and duplicate it > [end of test] appSta
|
||||
"id2": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -10880,6 +10918,7 @@ exports[`regression tests > noop interaction after undo shouldn't create history
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -11156,6 +11195,7 @@ exports[`regression tests > pinch-to-zoom works > [end of test] appState 1`] = `
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": "-6.25000",
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -11285,6 +11325,7 @@ exports[`regression tests > shift click on selected element should deselect it o
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -11486,6 +11527,7 @@ exports[`regression tests > shift-click to multiselect, then drag > [end of test
|
||||
"id1": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -11799,6 +11841,7 @@ exports[`regression tests > should group elements and ungroup them > [end of tes
|
||||
"id2": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -12213,6 +12256,7 @@ exports[`regression tests > single-clicking on a subgroup of a selected group sh
|
||||
"id6": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -12825,6 +12869,7 @@ exports[`regression tests > spacebar + drag scrolls the canvas > [end of test] a
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 60,
|
||||
"scrollY": 60,
|
||||
"scrolledOutside": false,
|
||||
@ -12954,6 +12999,7 @@ exports[`regression tests > supports nested groups > [end of test] appState 1`]
|
||||
"id0": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -13540,6 +13586,7 @@ exports[`regression tests > switches from group of selected elements to another
|
||||
"id2": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -13878,6 +13925,7 @@ exports[`regression tests > switches selected element on pointer down > [end of
|
||||
"id1": true,
|
||||
},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -14142,6 +14190,7 @@ exports[`regression tests > two-finger scroll works > [end of test] appState 1`]
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 20,
|
||||
"scrollY": "-18.53553",
|
||||
"scrolledOutside": false,
|
||||
@ -14269,6 +14318,7 @@ exports[`regression tests > undo/redo drawing an element > [end of test] appStat
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -14649,6 +14699,7 @@ exports[`regression tests > updates fontSize & fontFamily appState > [end of tes
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
@ -14779,6 +14830,7 @@ exports[`regression tests > zoom hotkeys > [end of test] appState 1`] = `
|
||||
"pendingImageElementId": null,
|
||||
"previousSelectedElementIds": {},
|
||||
"resizingElement": null,
|
||||
"scrollConstraints": null,
|
||||
"scrollX": 0,
|
||||
"scrollY": 0,
|
||||
"scrolledOutside": false,
|
||||
|
@ -20,7 +20,7 @@ import {
|
||||
isTextElement,
|
||||
isFrameLikeElement,
|
||||
} from "@excalidraw/element/typeChecks";
|
||||
import { KEYS, arrayToMap } from "@excalidraw/common";
|
||||
import { KEYS, arrayToMap, elementCenterPoint } from "@excalidraw/common";
|
||||
|
||||
import type { GlobalPoint, LocalPoint, Radians } from "@excalidraw/math";
|
||||
|
||||
@ -151,7 +151,7 @@ export class Keyboard {
|
||||
const getElementPointForSelection = (
|
||||
element: ExcalidrawElement,
|
||||
): GlobalPoint => {
|
||||
const { x, y, width, height, angle } = element;
|
||||
const { x, y, width, angle } = element;
|
||||
const target = pointFrom<GlobalPoint>(
|
||||
x +
|
||||
(isLinearElement(element) || isFreeDrawElement(element) ? 0 : width / 2),
|
||||
@ -166,7 +166,7 @@ const getElementPointForSelection = (
|
||||
(bounds[1] + bounds[3]) / 2,
|
||||
);
|
||||
} else {
|
||||
center = pointFrom(x + width / 2, y + height / 2);
|
||||
center = elementCenterPoint(element);
|
||||
}
|
||||
|
||||
if (isTextElement(element)) {
|
||||
|
@ -422,6 +422,7 @@ export interface AppState {
|
||||
userToFollow: UserToFollow | null;
|
||||
/** the socket ids of the users following the current user */
|
||||
followedBy: Set<SocketId>;
|
||||
scrollConstraints: ScrollConstraints | null;
|
||||
|
||||
/** image cropping */
|
||||
isCropping: boolean;
|
||||
@ -589,6 +590,7 @@ export interface ExcalidrawProps {
|
||||
onScrollChange?: (scrollX: number, scrollY: number, zoom: Zoom) => void;
|
||||
onUserFollow?: (payload: OnUserFollowedPayload) => void;
|
||||
children?: React.ReactNode;
|
||||
scrollConstraints?: AppState["scrollConstraints"];
|
||||
validateEmbeddable?:
|
||||
| boolean
|
||||
| string[]
|
||||
@ -834,6 +836,7 @@ export interface ExcalidrawImperativeAPI {
|
||||
onUserFollow: (
|
||||
callback: (payload: OnUserFollowedPayload) => void,
|
||||
) => UnsubscribeCallback;
|
||||
setScrollConstraints: InstanceType<typeof App>["setScrollConstraints"];
|
||||
}
|
||||
|
||||
export type Device = Readonly<{
|
||||
@ -869,6 +872,12 @@ export type FrameNameBoundsCache = {
|
||||
>;
|
||||
};
|
||||
|
||||
export type AnimateTranslateCanvasValues = {
|
||||
scrollX: AppState["scrollX"];
|
||||
scrollY: AppState["scrollY"];
|
||||
zoom: AppState["zoom"]["value"];
|
||||
};
|
||||
|
||||
export type KeyboardModifiersObject = {
|
||||
ctrlKey: boolean;
|
||||
shiftKey: boolean;
|
||||
@ -894,6 +903,16 @@ export type EmbedsValidationStatus = Map<
|
||||
|
||||
export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
|
||||
|
||||
export type ScrollConstraints = {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
animateOnNextUpdate?: boolean;
|
||||
viewportZoomFactor?: number;
|
||||
lockZoom?: boolean;
|
||||
overscrollAllowance?: number;
|
||||
};
|
||||
export type PendingExcalidrawElements = ExcalidrawElement[];
|
||||
|
||||
/** Runtime gridSize value. Null indicates disabled grid. */
|
||||
|
@ -31,6 +31,7 @@ import {
|
||||
mockBoundingClientRect,
|
||||
restoreOriginalGetBoundingClientRect,
|
||||
} from "../tests/test-utils";
|
||||
import { actionBindText } from "../actions";
|
||||
|
||||
unmountComponent();
|
||||
|
||||
@ -1568,5 +1569,101 @@ describe("textWysiwyg", () => {
|
||||
expect(text.containerId).toBe(null);
|
||||
expect(text.text).toBe("Excalidraw");
|
||||
});
|
||||
|
||||
it("should reset the text element angle to the container's when binding to rotated non-arrow container", async () => {
|
||||
const text = API.createElement({
|
||||
type: "text",
|
||||
text: "Hello World!",
|
||||
angle: 45,
|
||||
});
|
||||
const rectangle = API.createElement({
|
||||
type: "rectangle",
|
||||
width: 90,
|
||||
height: 75,
|
||||
angle: 30,
|
||||
});
|
||||
|
||||
API.setElements([rectangle, text]);
|
||||
|
||||
API.setSelectedElements([rectangle, text]);
|
||||
|
||||
h.app.actionManager.executeAction(actionBindText);
|
||||
|
||||
expect(text.angle).toBe(30);
|
||||
expect(rectangle.angle).toBe(30);
|
||||
});
|
||||
|
||||
it("should reset the text element angle to 0 when binding to rotated arrow container", async () => {
|
||||
const text = API.createElement({
|
||||
type: "text",
|
||||
text: "Hello World!",
|
||||
angle: 45,
|
||||
});
|
||||
const arrow = API.createElement({
|
||||
type: "arrow",
|
||||
width: 90,
|
||||
height: 75,
|
||||
angle: 30,
|
||||
});
|
||||
|
||||
API.setElements([arrow, text]);
|
||||
|
||||
API.setSelectedElements([arrow, text]);
|
||||
|
||||
h.app.actionManager.executeAction(actionBindText);
|
||||
|
||||
expect(text.angle).toBe(0);
|
||||
expect(arrow.angle).toBe(30);
|
||||
});
|
||||
|
||||
it("should keep the text label at 0 degrees when used as an arrow label", async () => {
|
||||
const arrow = API.createElement({
|
||||
type: "arrow",
|
||||
width: 90,
|
||||
height: 75,
|
||||
angle: 30,
|
||||
});
|
||||
|
||||
API.setElements([arrow]);
|
||||
API.setSelectedElements([arrow]);
|
||||
|
||||
mouse.doubleClickAt(
|
||||
arrow.x + arrow.width / 2,
|
||||
arrow.y + arrow.height / 2,
|
||||
);
|
||||
|
||||
const editor = await getTextEditor(textEditorSelector, true);
|
||||
|
||||
updateTextEditor(editor, "Hello World!");
|
||||
|
||||
Keyboard.exitTextEditor(editor);
|
||||
|
||||
expect(h.elements[1].angle).toBe(0);
|
||||
});
|
||||
|
||||
it("should keep the text label at the same degrees when used as a non-arrow label", async () => {
|
||||
const rectangle = API.createElement({
|
||||
type: "rectangle",
|
||||
width: 90,
|
||||
height: 75,
|
||||
angle: 30,
|
||||
});
|
||||
|
||||
API.setElements([rectangle]);
|
||||
API.setSelectedElements([rectangle]);
|
||||
|
||||
mouse.doubleClickAt(
|
||||
rectangle.x + rectangle.width / 2,
|
||||
rectangle.y + rectangle.height / 2,
|
||||
);
|
||||
|
||||
const editor = await getTextEditor(textEditorSelector, true);
|
||||
|
||||
updateTextEditor(editor, "Hello World!");
|
||||
|
||||
Keyboard.exitTextEditor(editor);
|
||||
|
||||
expect(h.elements[1].angle).toBe(30);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -41,6 +41,34 @@ export const polygonIncludesPoint = <Point extends LocalPoint | GlobalPoint>(
|
||||
return inside;
|
||||
};
|
||||
|
||||
export const polygonIncludesPointNonZero = <Point extends [number, number]>(
|
||||
point: Point,
|
||||
polygon: Point[],
|
||||
): boolean => {
|
||||
const [x, y] = point;
|
||||
let windingNumber = 0;
|
||||
|
||||
for (let i = 0; i < polygon.length; i++) {
|
||||
const j = (i + 1) % polygon.length;
|
||||
const [xi, yi] = polygon[i];
|
||||
const [xj, yj] = polygon[j];
|
||||
|
||||
if (yi <= y) {
|
||||
if (yj > y) {
|
||||
if ((xj - xi) * (y - yi) - (x - xi) * (yj - yi) > 0) {
|
||||
windingNumber++;
|
||||
}
|
||||
}
|
||||
} else if (yj <= y) {
|
||||
if ((xj - xi) * (y - yi) - (x - xi) * (yj - yi) < 0) {
|
||||
windingNumber--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return windingNumber !== 0;
|
||||
};
|
||||
|
||||
export const pointOnPolygon = <Point extends LocalPoint | GlobalPoint>(
|
||||
p: Point,
|
||||
poly: Polygon<Point>,
|
||||
|
@ -53,7 +53,14 @@ export const exportToCanvas = ({
|
||||
const { exportBackground, viewBackgroundColor } = restoredAppState;
|
||||
return _exportToCanvas(
|
||||
restoredElements,
|
||||
{ ...restoredAppState, offsetTop: 0, offsetLeft: 0, width: 0, height: 0 },
|
||||
{
|
||||
...restoredAppState,
|
||||
offsetTop: 0,
|
||||
offsetLeft: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
scrollConstraints: null,
|
||||
},
|
||||
files || {},
|
||||
{ exportBackground, exportPadding, viewBackgroundColor, exportingFrame },
|
||||
(width: number, height: number) => {
|
||||
|
Reference in New Issue
Block a user