Compare commits
87 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 39a8bcb3a4 | |||
| 3ee618497c | |||
| eabf18331b | |||
| 110afc3c85 | |||
| 23a6b6d3df | |||
| f6ced89c3c | |||
| 6eb0596638 | |||
| 0607003903 | |||
| 4e2026e47d | |||
| 67260915cb | |||
| c84fad4436 | |||
| 2e9c8851b3 | |||
| 19608b712f | |||
| 3a566a292c | |||
| 62c800c21a | |||
| f9723e2d19 | |||
| ffbd4a5dc8 | |||
| 5dded6112c | |||
| 84c396aec2 | |||
| bc6cc83b1e | |||
| baa7b3293a | |||
| 4208c97b62 | |||
| 2d0c0afa34 | |||
| df26487936 | |||
| 782772cec5 | |||
| 39f79927ae | |||
| 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 |
+338
-13
@@ -4,6 +4,7 @@ import {
|
|||||||
TTDDialogTrigger,
|
TTDDialogTrigger,
|
||||||
CaptureUpdateAction,
|
CaptureUpdateAction,
|
||||||
reconcileElements,
|
reconcileElements,
|
||||||
|
getCommonBounds,
|
||||||
useEditorInterface,
|
useEditorInterface,
|
||||||
} from "@excalidraw/excalidraw";
|
} from "@excalidraw/excalidraw";
|
||||||
import { trackEvent } from "@excalidraw/excalidraw/analytics";
|
import { trackEvent } from "@excalidraw/excalidraw/analytics";
|
||||||
@@ -57,9 +58,21 @@ import {
|
|||||||
useHandleLibrary,
|
useHandleLibrary,
|
||||||
} from "@excalidraw/excalidraw/data/library";
|
} 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 { RemoteExcalidrawElement } from "@excalidraw/excalidraw/data/reconcile";
|
||||||
import type { RestoredDataState } from "@excalidraw/excalidraw/data/restore";
|
import type { RestoredDataState } from "@excalidraw/excalidraw/data/restore";
|
||||||
import type {
|
import type {
|
||||||
|
ExcalidrawElement,
|
||||||
FileId,
|
FileId,
|
||||||
NonDeletedExcalidrawElement,
|
NonDeletedExcalidrawElement,
|
||||||
OrderedExcalidrawElement,
|
OrderedExcalidrawElement,
|
||||||
@@ -70,8 +83,9 @@ import type {
|
|||||||
BinaryFiles,
|
BinaryFiles,
|
||||||
ExcalidrawInitialDataState,
|
ExcalidrawInitialDataState,
|
||||||
UIAppState,
|
UIAppState,
|
||||||
|
ScrollConstraints,
|
||||||
} from "@excalidraw/excalidraw/types";
|
} 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 type { ResolvablePromise } from "@excalidraw/common/utils";
|
||||||
|
|
||||||
import CustomStats from "./CustomStats";
|
import CustomStats from "./CustomStats";
|
||||||
@@ -145,6 +159,274 @@ import type { CollabAPI } from "./collab/Collab";
|
|||||||
|
|
||||||
polyfill();
|
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;
|
window.EXCALIDRAW_THROTTLE_RENDER = true;
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@@ -216,10 +498,20 @@ const initializeScene = async (opts: {
|
|||||||
)
|
)
|
||||||
> => {
|
> => {
|
||||||
const searchParams = new URLSearchParams(window.location.search);
|
const searchParams = new URLSearchParams(window.location.search);
|
||||||
|
const hashParams = new URLSearchParams(window.location.hash.slice(1));
|
||||||
const id = searchParams.get("id");
|
const id = searchParams.get("id");
|
||||||
const jsonBackendMatch = window.location.hash.match(
|
const shareableLink = hashParams.get("json")?.split(",");
|
||||||
/^#json=([a-zA-Z0-9_-]+),([a-zA-Z0-9_-]+)$/,
|
|
||||||
);
|
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 externalUrlMatch = window.location.hash.match(/^#url=(.*)$/);
|
||||||
|
|
||||||
const localDataState = importFromLocalStorage();
|
const localDataState = importFromLocalStorage();
|
||||||
@@ -229,7 +521,7 @@ const initializeScene = async (opts: {
|
|||||||
} = await loadScene(null, null, localDataState);
|
} = await loadScene(null, null, localDataState);
|
||||||
|
|
||||||
let roomLinkData = getCollaborationLinkData(window.location.href);
|
let roomLinkData = getCollaborationLinkData(window.location.href);
|
||||||
const isExternalScene = !!(id || jsonBackendMatch || roomLinkData);
|
const isExternalScene = !!(id || shareableLink || roomLinkData);
|
||||||
if (isExternalScene) {
|
if (isExternalScene) {
|
||||||
if (
|
if (
|
||||||
// don't prompt if scene is empty
|
// don't prompt if scene is empty
|
||||||
@@ -239,16 +531,16 @@ const initializeScene = async (opts: {
|
|||||||
// otherwise, prompt whether user wants to override current scene
|
// otherwise, prompt whether user wants to override current scene
|
||||||
(await openConfirmModal(shareableLinkConfirmDialog))
|
(await openConfirmModal(shareableLinkConfirmDialog))
|
||||||
) {
|
) {
|
||||||
if (jsonBackendMatch) {
|
if (shareableLink) {
|
||||||
scene = await loadScene(
|
scene = await loadScene(
|
||||||
jsonBackendMatch[1],
|
shareableLink[0],
|
||||||
jsonBackendMatch[2],
|
shareableLink[1],
|
||||||
localDataState,
|
localDataState,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
scene.scrollToContent = true;
|
scene.scrollToContent = true;
|
||||||
if (!roomLinkData) {
|
if (!roomLinkData) {
|
||||||
window.history.replaceState({}, APP_NAME, window.location.origin);
|
// window.history.replaceState({}, APP_NAME, window.location.origin);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// https://github.com/excalidraw/excalidraw/issues/1919
|
// https://github.com/excalidraw/excalidraw/issues/1919
|
||||||
@@ -265,7 +557,7 @@ const initializeScene = async (opts: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
roomLinkData = null;
|
roomLinkData = null;
|
||||||
window.history.replaceState({}, APP_NAME, window.location.origin);
|
// window.history.replaceState({}, APP_NAME, window.location.origin);
|
||||||
}
|
}
|
||||||
} else if (externalUrlMatch) {
|
} else if (externalUrlMatch) {
|
||||||
window.history.replaceState({}, APP_NAME, window.location.origin);
|
window.history.replaceState({}, APP_NAME, window.location.origin);
|
||||||
@@ -326,12 +618,12 @@ const initializeScene = async (opts: {
|
|||||||
key: roomLinkData.roomKey,
|
key: roomLinkData.roomKey,
|
||||||
};
|
};
|
||||||
} else if (scene) {
|
} else if (scene) {
|
||||||
return isExternalScene && jsonBackendMatch
|
return isExternalScene && shareableLink
|
||||||
? {
|
? {
|
||||||
scene,
|
scene,
|
||||||
isExternalScene,
|
isExternalScene,
|
||||||
id: jsonBackendMatch[1],
|
id: shareableLink[0],
|
||||||
key: jsonBackendMatch[2],
|
key: shareableLink[1],
|
||||||
}
|
}
|
||||||
: { scene, isExternalScene: false };
|
: { scene, isExternalScene: false };
|
||||||
}
|
}
|
||||||
@@ -741,6 +1033,32 @@ const ExcalidrawWrapper = () => {
|
|||||||
[setShareDialogState],
|
[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
|
// browsers generally prevent infinite self-embedding, there are
|
||||||
// cases where it still happens, and while we disallow self-embedding
|
// cases where it still happens, and while we disallow self-embedding
|
||||||
// by not whitelisting our own origin, this serves as an additional guard
|
// by not whitelisting our own origin, this serves as an additional guard
|
||||||
@@ -874,6 +1192,7 @@ const ExcalidrawWrapper = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
// scrollConstraints={constraints.enabled ? constraints : undefined}
|
||||||
onLinkOpen={(element, event) => {
|
onLinkOpen={(element, event) => {
|
||||||
if (element.link && isElementLink(element.link)) {
|
if (element.link && isElementLink(element.link)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -881,6 +1200,12 @@ const ExcalidrawWrapper = () => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{/* {excalidrawAPI && !isTestEnv() && (
|
||||||
|
<ConstraintsSettings
|
||||||
|
excalidrawAPI={excalidrawAPI}
|
||||||
|
initialConstraints={constraints}
|
||||||
|
/>
|
||||||
|
)} */}
|
||||||
<AppMainMenu
|
<AppMainMenu
|
||||||
onCollabDialogOpen={onCollabDialogOpen}
|
onCollabDialogOpen={onCollabDialogOpen}
|
||||||
isCollaborating={isCollaborating}
|
isCollaborating={isCollaborating}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import {
|
|||||||
ZoomResetIcon,
|
ZoomResetIcon,
|
||||||
} from "../components/icons";
|
} from "../components/icons";
|
||||||
import { setCursor } from "../cursor";
|
import { setCursor } from "../cursor";
|
||||||
|
import { constrainScrollState } from "../scene/scrollConstraints";
|
||||||
|
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { getNormalizedZoom } from "../scene";
|
import { getNormalizedZoom } from "../scene";
|
||||||
@@ -140,7 +141,7 @@ export const actionZoomIn = register({
|
|||||||
trackEvent: { category: "canvas" },
|
trackEvent: { category: "canvas" },
|
||||||
perform: (_elements, appState, _, app) => {
|
perform: (_elements, appState, _, app) => {
|
||||||
return {
|
return {
|
||||||
appState: {
|
appState: constrainScrollState({
|
||||||
...appState,
|
...appState,
|
||||||
...getStateForZoom(
|
...getStateForZoom(
|
||||||
{
|
{
|
||||||
@@ -151,7 +152,7 @@ export const actionZoomIn = register({
|
|||||||
appState,
|
appState,
|
||||||
),
|
),
|
||||||
userToFollow: null,
|
userToFollow: null,
|
||||||
},
|
}),
|
||||||
captureUpdate: CaptureUpdateAction.EVENTUALLY,
|
captureUpdate: CaptureUpdateAction.EVENTUALLY,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -181,7 +182,7 @@ export const actionZoomOut = register({
|
|||||||
trackEvent: { category: "canvas" },
|
trackEvent: { category: "canvas" },
|
||||||
perform: (_elements, appState, _, app) => {
|
perform: (_elements, appState, _, app) => {
|
||||||
return {
|
return {
|
||||||
appState: {
|
appState: constrainScrollState({
|
||||||
...appState,
|
...appState,
|
||||||
...getStateForZoom(
|
...getStateForZoom(
|
||||||
{
|
{
|
||||||
@@ -192,7 +193,7 @@ export const actionZoomOut = register({
|
|||||||
appState,
|
appState,
|
||||||
),
|
),
|
||||||
userToFollow: null,
|
userToFollow: null,
|
||||||
},
|
}),
|
||||||
captureUpdate: CaptureUpdateAction.EVENTUALLY,
|
captureUpdate: CaptureUpdateAction.EVENTUALLY,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const defaultExportScale = EXPORT_SCALES.includes(devicePixelRatio)
|
|||||||
|
|
||||||
export const getDefaultAppState = (): Omit<
|
export const getDefaultAppState = (): Omit<
|
||||||
AppState,
|
AppState,
|
||||||
"offsetTop" | "offsetLeft" | "width" | "height"
|
"offsetTop" | "offsetLeft" | "width" | "height" | "scrollConstraints"
|
||||||
> => {
|
> => {
|
||||||
return {
|
return {
|
||||||
showWelcomeScreen: false,
|
showWelcomeScreen: false,
|
||||||
@@ -247,6 +247,7 @@ const APP_STATE_STORAGE_CONF = (<
|
|||||||
objectsSnapModeEnabled: { browser: true, export: false, server: false },
|
objectsSnapModeEnabled: { browser: true, export: false, server: false },
|
||||||
userToFollow: { browser: false, export: false, server: false },
|
userToFollow: { browser: false, export: false, server: false },
|
||||||
followedBy: { 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 },
|
isCropping: { browser: false, export: false, server: false },
|
||||||
croppingElementId: { browser: false, export: false, server: false },
|
croppingElementId: { browser: false, export: false, server: false },
|
||||||
searchMatches: { browser: false, export: false, server: false },
|
searchMatches: { browser: false, export: false, server: false },
|
||||||
|
|||||||
@@ -404,6 +404,11 @@ import { isMaybeMermaidDefinition } from "../mermaid";
|
|||||||
|
|
||||||
import { LassoTrail } from "../lasso";
|
import { LassoTrail } from "../lasso";
|
||||||
|
|
||||||
|
import {
|
||||||
|
constrainScrollState,
|
||||||
|
calculateConstrainedScrollCenter,
|
||||||
|
areCanvasTranslatesClose,
|
||||||
|
} from "../scene/scrollConstraints";
|
||||||
import { EraserTrail } from "../eraser";
|
import { EraserTrail } from "../eraser";
|
||||||
|
|
||||||
import { getShortcutKey } from "../shortcut";
|
import { getShortcutKey } from "../shortcut";
|
||||||
@@ -464,6 +469,8 @@ import type {
|
|||||||
FrameNameBoundsCache,
|
FrameNameBoundsCache,
|
||||||
SidebarName,
|
SidebarName,
|
||||||
SidebarTabName,
|
SidebarTabName,
|
||||||
|
ScrollConstraints,
|
||||||
|
AnimateTranslateCanvasValues,
|
||||||
KeyboardModifiersObject,
|
KeyboardModifiersObject,
|
||||||
CollaboratorPointer,
|
CollaboratorPointer,
|
||||||
ToolType,
|
ToolType,
|
||||||
@@ -513,6 +520,7 @@ const ExcalidrawAppStateContext = React.createContext<AppState>({
|
|||||||
height: 0,
|
height: 0,
|
||||||
offsetLeft: 0,
|
offsetLeft: 0,
|
||||||
offsetTop: 0,
|
offsetTop: 0,
|
||||||
|
scrollConstraints: null,
|
||||||
});
|
});
|
||||||
ExcalidrawAppStateContext.displayName = "ExcalidrawAppStateContext";
|
ExcalidrawAppStateContext.displayName = "ExcalidrawAppStateContext";
|
||||||
|
|
||||||
@@ -554,6 +562,8 @@ let isDraggingScrollBar: boolean = false;
|
|||||||
let currentScrollBars: ScrollBars = { horizontal: null, vertical: null };
|
let currentScrollBars: ScrollBars = { horizontal: null, vertical: null };
|
||||||
let touchTimeout = 0;
|
let touchTimeout = 0;
|
||||||
let invalidateContextMenu = false;
|
let invalidateContextMenu = false;
|
||||||
|
let scrollConstraintsAnimationTimeout: ReturnType<typeof setTimeout> | null =
|
||||||
|
null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of youtube embed video states
|
* Map of youtube embed video states
|
||||||
@@ -685,7 +695,9 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
objectsSnapModeEnabled = false,
|
objectsSnapModeEnabled = false,
|
||||||
theme = defaultAppState.theme,
|
theme = defaultAppState.theme,
|
||||||
name = `${t("labels.untitled")}-${getDateTime()}`,
|
name = `${t("labels.untitled")}-${getDateTime()}`,
|
||||||
|
scrollConstraints,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
...defaultAppState,
|
...defaultAppState,
|
||||||
theme,
|
theme,
|
||||||
@@ -698,6 +710,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
name,
|
name,
|
||||||
width: window.innerWidth,
|
width: window.innerWidth,
|
||||||
height: window.innerHeight,
|
height: window.innerHeight,
|
||||||
|
scrollConstraints: scrollConstraints ?? null,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.refreshEditorInterface();
|
this.refreshEditorInterface();
|
||||||
@@ -752,6 +765,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
getEditorInterface: () => this.editorInterface,
|
getEditorInterface: () => this.editorInterface,
|
||||||
updateFrameRendering: this.updateFrameRendering,
|
updateFrameRendering: this.updateFrameRendering,
|
||||||
toggleSidebar: this.toggleSidebar,
|
toggleSidebar: this.toggleSidebar,
|
||||||
|
setScrollConstraints: this.setScrollConstraints,
|
||||||
onChange: (cb) => this.onChangeEmitter.on(cb),
|
onChange: (cb) => this.onChangeEmitter.on(cb),
|
||||||
onIncrement: (cb) => this.store.onStoreIncrementEmitter.on(cb),
|
onIncrement: (cb) => this.store.onStoreIncrementEmitter.on(cb),
|
||||||
onPointerDown: (cb) => this.onPointerDownEmitter.on(cb),
|
onPointerDown: (cb) => this.onPointerDownEmitter.on(cb),
|
||||||
@@ -2409,7 +2423,12 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
toast: this.state.toast,
|
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 = {
|
||||||
...scene.appState,
|
...scene.appState,
|
||||||
...calculateScrollCenter(scene.elements, {
|
...calculateScrollCenter(scene.elements, {
|
||||||
@@ -2418,6 +2437,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
height: this.state.height,
|
height: this.state.height,
|
||||||
offsetTop: this.state.offsetTop,
|
offsetTop: this.state.offsetTop,
|
||||||
offsetLeft: this.state.offsetLeft,
|
offsetLeft: this.state.offsetLeft,
|
||||||
|
scrollConstraints: this.state.scrollConstraints,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -2638,7 +2658,11 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
.forEach((element) => ShapeCache.delete(element));
|
.forEach((element) => ShapeCache.delete(element));
|
||||||
this.refreshEditorInterface();
|
this.refreshEditorInterface();
|
||||||
this.updateDOMRect();
|
this.updateDOMRect();
|
||||||
this.setState({});
|
if (this.state.scrollConstraints) {
|
||||||
|
this.setState((state) => constrainScrollState(state));
|
||||||
|
} else {
|
||||||
|
this.setState({});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/** generally invoked only if fullscreen was invoked programmatically */
|
/** generally invoked only if fullscreen was invoked programmatically */
|
||||||
@@ -2940,6 +2964,33 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
this.props.onChange?.(elements, this.state, this.files);
|
this.props.onChange?.(elements, this.state, this.files);
|
||||||
this.onChangeEmitter.trigger(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 = ({
|
private renderInteractiveSceneCallback = ({
|
||||||
@@ -3698,8 +3749,8 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
*/
|
*/
|
||||||
value: number,
|
value: number,
|
||||||
) => {
|
) => {
|
||||||
this.setState({
|
this.setState(
|
||||||
...getStateForZoom(
|
getStateForZoom(
|
||||||
{
|
{
|
||||||
viewportX: this.state.width / 2 + this.state.offsetLeft,
|
viewportX: this.state.width / 2 + this.state.offsetLeft,
|
||||||
viewportY: this.state.height / 2 + this.state.offsetTop,
|
viewportY: this.state.height / 2 + this.state.offsetTop,
|
||||||
@@ -3707,7 +3758,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
},
|
},
|
||||||
this.state,
|
this.state,
|
||||||
),
|
),
|
||||||
});
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
private cancelInProgressAnimation: (() => void) | null = null;
|
private cancelInProgressAnimation: (() => void) | null = null;
|
||||||
@@ -3807,32 +3858,18 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
// when animating, we use RequestAnimationFrame to prevent the animation
|
// when animating, we use RequestAnimationFrame to prevent the animation
|
||||||
// from slowing down other processes
|
// from slowing down other processes
|
||||||
if (opts?.animate) {
|
if (opts?.animate) {
|
||||||
const origScrollX = this.state.scrollX;
|
const fromValues = {
|
||||||
const origScrollY = this.state.scrollY;
|
scrollX: this.state.scrollX,
|
||||||
const origZoom = this.state.zoom.value;
|
scrollY: this.state.scrollY,
|
||||||
|
zoom: this.state.zoom.value,
|
||||||
|
};
|
||||||
|
|
||||||
const cancel = easeToValuesRAF({
|
const toValues = { scrollX, scrollY, zoom: zoom.value };
|
||||||
fromValues: {
|
|
||||||
scrollX: origScrollX,
|
this.animateTranslateCanvas({
|
||||||
scrollY: origScrollY,
|
fromValues,
|
||||||
zoom: origZoom,
|
toValues,
|
||||||
},
|
duration: opts?.duration ?? 500,
|
||||||
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 },
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onStart: () => {
|
onStart: () => {
|
||||||
this.setState({ shouldCacheIgnoreZoom: true });
|
this.setState({ shouldCacheIgnoreZoom: true });
|
||||||
},
|
},
|
||||||
@@ -3842,13 +3879,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
onCancel: () => {
|
onCancel: () => {
|
||||||
this.setState({ shouldCacheIgnoreZoom: false });
|
this.setState({ shouldCacheIgnoreZoom: false });
|
||||||
},
|
},
|
||||||
duration: opts?.duration ?? 500,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.cancelInProgressAnimation = () => {
|
|
||||||
cancel();
|
|
||||||
this.cancelInProgressAnimation = null;
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
this.setState({ scrollX, scrollY, zoom });
|
this.setState({ scrollX, scrollY, zoom });
|
||||||
}
|
}
|
||||||
@@ -3862,11 +3893,158 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
|
|
||||||
/** use when changing scrollX/scrollY/zoom based on user interaction */
|
/** use when changing scrollX/scrollY/zoom based on user interaction */
|
||||||
private translateCanvas: React.Component<any, AppState>["setState"] = (
|
private translateCanvas: React.Component<any, AppState>["setState"] = (
|
||||||
state,
|
stateUpdate,
|
||||||
) => {
|
) => {
|
||||||
this.cancelInProgressAnimation?.();
|
this.cancelInProgressAnimation?.();
|
||||||
this.maybeUnfollowRemoteUser();
|
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 = (
|
setToast = (
|
||||||
@@ -4932,16 +5110,22 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
|
|
||||||
const initialScale = gesture.initialScale;
|
const initialScale = gesture.initialScale;
|
||||||
if (initialScale) {
|
if (initialScale) {
|
||||||
this.setState((state) => ({
|
this.setState((state) =>
|
||||||
...getStateForZoom(
|
constrainScrollState(
|
||||||
{
|
{
|
||||||
viewportX: this.lastViewportPosition.x,
|
...state,
|
||||||
viewportY: this.lastViewportPosition.y,
|
...getStateForZoom(
|
||||||
nextZoom: getNormalizedZoom(initialScale * event.scale),
|
{
|
||||||
|
viewportX: this.lastViewportPosition.x,
|
||||||
|
viewportY: this.lastViewportPosition.y,
|
||||||
|
nextZoom: getNormalizedZoom(initialScale * event.scale),
|
||||||
|
},
|
||||||
|
state,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
state,
|
"loose",
|
||||||
),
|
),
|
||||||
}));
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -11459,6 +11643,51 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
await setLanguage(currentLang);
|
await setLanguage(currentLang);
|
||||||
this.setAppState({});
|
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -614,7 +614,7 @@ const LayerUI = ({
|
|||||||
showExitZenModeBtn={showExitZenModeBtn}
|
showExitZenModeBtn={showExitZenModeBtn}
|
||||||
renderWelcomeScreen={renderWelcomeScreen}
|
renderWelcomeScreen={renderWelcomeScreen}
|
||||||
/>
|
/>
|
||||||
{appState.scrolledOutside && (
|
{appState.scrolledOutside && !appState.scrollConstraints && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="scroll-back-to-content"
|
className="scroll-back-to-content"
|
||||||
|
|||||||
@@ -155,7 +155,8 @@ export const MobileMenu = ({
|
|||||||
renderToolbar()}
|
renderToolbar()}
|
||||||
{appState.scrolledOutside &&
|
{appState.scrolledOutside &&
|
||||||
!appState.openMenu &&
|
!appState.openMenu &&
|
||||||
!appState.openSidebar && (
|
!appState.openSidebar &&
|
||||||
|
!appState.scrollConstraints && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="scroll-back-to-content"
|
className="scroll-back-to-content"
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ import type { ImportedDataState, LegacyAppState } from "./types";
|
|||||||
|
|
||||||
type RestoredAppState = Omit<
|
type RestoredAppState = Omit<
|
||||||
AppState,
|
AppState,
|
||||||
"offsetTop" | "offsetLeft" | "width" | "height"
|
"offsetTop" | "offsetLeft" | "width" | "height" | "scrollConstraints"
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export const AllowedExcalidrawActiveTools: Record<
|
export const AllowedExcalidrawActiveTools: Record<
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ const canvas = exportToCanvas(
|
|||||||
offsetLeft: 0,
|
offsetLeft: 0,
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0,
|
||||||
|
scrollConstraints: null,
|
||||||
},
|
},
|
||||||
{}, // files
|
{}, // files
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
|
|||||||
onScrollChange,
|
onScrollChange,
|
||||||
onDuplicate,
|
onDuplicate,
|
||||||
children,
|
children,
|
||||||
|
scrollConstraints,
|
||||||
validateEmbeddable,
|
validateEmbeddable,
|
||||||
renderEmbeddable,
|
renderEmbeddable,
|
||||||
aiEnabled,
|
aiEnabled,
|
||||||
@@ -124,7 +125,10 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
|
|||||||
renderTopLeftUI={renderTopLeftUI}
|
renderTopLeftUI={renderTopLeftUI}
|
||||||
renderTopRightUI={renderTopRightUI}
|
renderTopRightUI={renderTopRightUI}
|
||||||
langCode={langCode}
|
langCode={langCode}
|
||||||
viewModeEnabled={viewModeEnabled}
|
viewModeEnabled={
|
||||||
|
viewModeEnabled ??
|
||||||
|
(scrollConstraints != null ? !!scrollConstraints : undefined)
|
||||||
|
}
|
||||||
zenModeEnabled={zenModeEnabled}
|
zenModeEnabled={zenModeEnabled}
|
||||||
gridModeEnabled={gridModeEnabled}
|
gridModeEnabled={gridModeEnabled}
|
||||||
libraryReturnUrl={libraryReturnUrl}
|
libraryReturnUrl={libraryReturnUrl}
|
||||||
@@ -143,6 +147,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
|
|||||||
onPointerDown={onPointerDown}
|
onPointerDown={onPointerDown}
|
||||||
onPointerUp={onPointerUp}
|
onPointerUp={onPointerUp}
|
||||||
onScrollChange={onScrollChange}
|
onScrollChange={onScrollChange}
|
||||||
|
scrollConstraints={scrollConstraints}
|
||||||
onDuplicate={onDuplicate}
|
onDuplicate={onDuplicate}
|
||||||
validateEmbeddable={validateEmbeddable}
|
validateEmbeddable={validateEmbeddable}
|
||||||
renderEmbeddable={renderEmbeddable}
|
renderEmbeddable={renderEmbeddable}
|
||||||
|
|||||||
@@ -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
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -147,6 +147,11 @@ export type ScrollBars = {
|
|||||||
} | null;
|
} | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ConstrainedScrollValues = Pick<
|
||||||
|
AppState,
|
||||||
|
"scrollX" | "scrollY" | "zoom"
|
||||||
|
> | null;
|
||||||
|
|
||||||
export type ElementShape = Drawable | Drawable[] | null;
|
export type ElementShape = Drawable | Drawable[] | null;
|
||||||
|
|
||||||
export type ElementShapes = {
|
export type ElementShapes = {
|
||||||
|
|||||||
@@ -962,6 +962,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -1160,6 +1161,7 @@ exports[`contextMenu element > selecting 'Add to library' in context menu adds e
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": true,
|
"scrolledOutside": true,
|
||||||
@@ -1376,6 +1378,7 @@ exports[`contextMenu element > selecting 'Bring forward' in context menu brings
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -1709,6 +1712,7 @@ exports[`contextMenu element > selecting 'Bring to front' in context menu brings
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -2042,6 +2046,7 @@ exports[`contextMenu element > selecting 'Copy styles' in context menu copies st
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": true,
|
"scrolledOutside": true,
|
||||||
@@ -2258,6 +2263,7 @@ exports[`contextMenu element > selecting 'Delete' in context menu deletes elemen
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -2501,6 +2507,7 @@ exports[`contextMenu element > selecting 'Duplicate' in context menu duplicates
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -2803,6 +2810,7 @@ exports[`contextMenu element > selecting 'Group selection' in context menu group
|
|||||||
"id3": true,
|
"id3": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -3175,6 +3183,7 @@ exports[`contextMenu element > selecting 'Paste styles' in context menu pastes s
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -3670,6 +3679,7 @@ exports[`contextMenu element > selecting 'Send backward' in context menu sends e
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -3995,6 +4005,7 @@ exports[`contextMenu element > selecting 'Send to back' in context menu sends el
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -4322,6 +4333,7 @@ exports[`contextMenu element > selecting 'Ungroup selection' in context menu ung
|
|||||||
"id3": true,
|
"id3": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -5609,6 +5621,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -6828,6 +6841,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -7766,6 +7780,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -8765,6 +8780,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": true,
|
"scrolledOutside": true,
|
||||||
@@ -9761,6 +9777,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
|||||||
"id4": true,
|
"id4": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -704,6 +705,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
|||||||
"id4": true,
|
"id4": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -1193,6 +1195,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -1559,6 +1562,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -1928,6 +1932,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -2190,6 +2195,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -2637,6 +2643,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -2942,6 +2949,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -3263,6 +3271,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -3559,6 +3568,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -3847,6 +3857,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -4084,6 +4095,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -4343,6 +4355,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -4616,6 +4629,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -4847,6 +4861,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -5078,6 +5093,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -5327,6 +5343,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -5585,6 +5602,7 @@ exports[`history > multiplayer undo/redo > conflicts in frames and their childre
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -5844,6 +5862,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
|||||||
"id1": true,
|
"id1": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -6175,6 +6194,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
|||||||
"id8": true,
|
"id8": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -6604,6 +6624,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
|||||||
"id1": true,
|
"id1": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -6981,6 +7002,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -7292,6 +7314,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -7610,6 +7633,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -7842,6 +7866,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -8196,6 +8221,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -8553,6 +8579,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
|||||||
"id3": true,
|
"id3": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -8958,6 +8985,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -9247,6 +9275,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -9513,6 +9542,7 @@ exports[`history > multiplayer undo/redo > should not override remote changes on
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -9780,6 +9810,7 @@ exports[`history > multiplayer undo/redo > should not override remote changes on
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -10017,6 +10048,7 @@ exports[`history > multiplayer undo/redo > should override remotely added groups
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -10313,6 +10345,7 @@ exports[`history > multiplayer undo/redo > should override remotely added points
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -10664,6 +10697,7 @@ exports[`history > multiplayer undo/redo > should redistribute deltas when eleme
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -10905,6 +10939,7 @@ exports[`history > multiplayer undo/redo > should redraw arrows on undo > [end o
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -11352,6 +11387,7 @@ exports[`history > multiplayer undo/redo > should update history entries after r
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -11614,6 +11650,7 @@ exports[`history > singleplayer undo/redo > remounting undo/redo buttons should
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -11851,6 +11888,7 @@ exports[`history > singleplayer undo/redo > should clear the redo stack on eleme
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -12090,6 +12128,7 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -12498,6 +12537,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on e
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -12707,6 +12747,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on e
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -12919,6 +12960,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on i
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -13219,6 +13261,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on i
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -13522,6 +13565,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on s
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": -50,
|
"scrollX": -50,
|
||||||
"scrollY": -50,
|
"scrollY": -50,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -13766,6 +13810,7 @@ exports[`history > singleplayer undo/redo > should disable undo/redo buttons whe
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -14005,6 +14050,7 @@ exports[`history > singleplayer undo/redo > should end up with no history entry
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -14246,6 +14292,7 @@ exports[`history > singleplayer undo/redo > should iterate through the history w
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -14493,6 +14540,7 @@ exports[`history > singleplayer undo/redo > should not clear the redo stack on s
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -14829,6 +14877,7 @@ exports[`history > singleplayer undo/redo > should not collapse when applying co
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -14998,6 +15047,7 @@ exports[`history > singleplayer undo/redo > should not end up with history entry
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -15287,6 +15337,7 @@ exports[`history > singleplayer undo/redo > should not end up with history entry
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -15552,6 +15603,7 @@ exports[`history > singleplayer undo/redo > should not modify anything on unrela
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -15706,6 +15758,7 @@ exports[`history > singleplayer undo/redo > should not override appstate changes
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -15991,6 +16044,7 @@ exports[`history > singleplayer undo/redo > should support appstate name or view
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -16154,6 +16208,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -16861,6 +16916,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -17498,6 +17554,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -18133,6 +18190,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -18856,6 +18914,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -19609,6 +19668,7 @@ exports[`history > singleplayer undo/redo > should support changes in elements'
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -20091,6 +20151,7 @@ exports[`history > singleplayer undo/redo > should support duplication of groups
|
|||||||
"id1": true,
|
"id1": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -20604,6 +20665,7 @@ exports[`history > singleplayer undo/redo > should support element creation, del
|
|||||||
"id3": true,
|
"id3": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
@@ -21065,6 +21127,7 @@ exports[`history > singleplayer undo/redo > should support linear element creati
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"searchMatches": null,
|
"searchMatches": null,
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ exports[`given element A and group of elements B and given both are selected whe
|
|||||||
"id6": true,
|
"id6": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -517,6 +518,7 @@ exports[`given element A and group of elements B and given both are selected whe
|
|||||||
"id6": true,
|
"id6": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -931,6 +933,7 @@ exports[`regression tests > Cmd/Ctrl-click exclusively select element under poin
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -1499,6 +1502,7 @@ exports[`regression tests > Drags selected element when hitting only bounding bo
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -1710,6 +1714,7 @@ exports[`regression tests > adjusts z order when grouping > [end of test] appSta
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -2096,6 +2101,7 @@ exports[`regression tests > alt-drag duplicates an element > [end of test] appSt
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -2341,6 +2347,7 @@ exports[`regression tests > arrow keys > [end of test] appState 1`] = `
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -2525,6 +2532,7 @@ exports[`regression tests > can drag element that covers another element, while
|
|||||||
"id6": true,
|
"id6": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -2850,6 +2858,7 @@ exports[`regression tests > change the properties of a shape > [end of test] app
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -3109,6 +3118,7 @@ exports[`regression tests > click on an element and drag it > [dragged] appState
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -3352,6 +3362,7 @@ exports[`regression tests > click on an element and drag it > [end of test] appS
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -3590,6 +3601,7 @@ exports[`regression tests > click to select a shape > [end of test] appState 1`]
|
|||||||
"id3": true,
|
"id3": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -3850,6 +3862,7 @@ exports[`regression tests > click-drag to select a group > [end of test] appStat
|
|||||||
"id6": true,
|
"id6": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -4164,6 +4177,7 @@ exports[`regression tests > deleting last but one element in editing group shoul
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -4605,6 +4619,7 @@ exports[`regression tests > deselects group of selected elements on pointer down
|
|||||||
"id3": true,
|
"id3": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -4890,6 +4905,7 @@ exports[`regression tests > deselects group of selected elements on pointer up w
|
|||||||
"id3": true,
|
"id3": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -5167,6 +5183,7 @@ exports[`regression tests > deselects selected element on pointer down when poin
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -5377,6 +5394,7 @@ exports[`regression tests > deselects selected element, on pointer up, when clic
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -5577,6 +5595,7 @@ exports[`regression tests > double click to edit a group > [end of test] appStat
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -5975,6 +5994,7 @@ exports[`regression tests > drags selected elements from point inside common bou
|
|||||||
"id3": true,
|
"id3": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -6271,6 +6291,7 @@ exports[`regression tests > draw every type of shape > [end of test] appState 1`
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -7132,6 +7153,7 @@ exports[`regression tests > given a group of selected elements with an element t
|
|||||||
"id6": true,
|
"id6": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -7467,6 +7489,7 @@ exports[`regression tests > given a selected element A and a not selected elemen
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -7748,6 +7771,7 @@ exports[`regression tests > given selected element A with lower z-index than uns
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -7985,6 +8009,7 @@ exports[`regression tests > given selected element A with lower z-index than uns
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -8225,6 +8250,7 @@ exports[`regression tests > key 2 selects rectangle tool > [end of test] appStat
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -8407,6 +8433,7 @@ exports[`regression tests > key 3 selects diamond tool > [end of test] appState
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -8589,6 +8616,7 @@ exports[`regression tests > key 4 selects ellipse tool > [end of test] appState
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -8771,6 +8799,7 @@ exports[`regression tests > key 5 selects arrow tool > [end of test] appState 1`
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -9003,6 +9032,7 @@ exports[`regression tests > key 6 selects line tool > [end of test] appState 1`]
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -9233,6 +9263,7 @@ exports[`regression tests > key 7 selects freedraw tool > [end of test] appState
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -9431,6 +9462,7 @@ exports[`regression tests > key a selects arrow tool > [end of test] appState 1`
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -9663,6 +9695,7 @@ exports[`regression tests > key d selects diamond tool > [end of test] appState
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -9845,6 +9878,7 @@ exports[`regression tests > key l selects line tool > [end of test] appState 1`]
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -10075,6 +10109,7 @@ exports[`regression tests > key o selects ellipse tool > [end of test] appState
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -10257,6 +10292,7 @@ exports[`regression tests > key p selects freedraw tool > [end of test] appState
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -10455,6 +10491,7 @@ exports[`regression tests > key r selects rectangle tool > [end of test] appStat
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -10641,6 +10678,7 @@ exports[`regression tests > make a group and duplicate it > [end of test] appSta
|
|||||||
"id6": true,
|
"id6": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -11172,6 +11210,7 @@ exports[`regression tests > noop interaction after undo shouldn't create history
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -11452,6 +11491,7 @@ exports[`regression tests > pinch-to-zoom works > [end of test] appState 1`] = `
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": "-6.25000",
|
"scrollX": "-6.25000",
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -11579,6 +11619,7 @@ exports[`regression tests > shift click on selected element should deselect it o
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -11782,6 +11823,7 @@ exports[`regression tests > shift-click to multiselect, then drag > [end of test
|
|||||||
"id3": true,
|
"id3": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -12104,6 +12146,7 @@ exports[`regression tests > should group elements and ungroup them > [end of tes
|
|||||||
"id6": true,
|
"id6": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -12536,6 +12579,7 @@ exports[`regression tests > single-clicking on a subgroup of a selected group sh
|
|||||||
"id3": true,
|
"id3": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -13176,6 +13220,7 @@ exports[`regression tests > spacebar + drag scrolls the canvas > [end of test] a
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 60,
|
"scrollX": 60,
|
||||||
"scrollY": 60,
|
"scrollY": 60,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -13303,6 +13348,7 @@ exports[`regression tests > supports nested groups > [end of test] appState 1`]
|
|||||||
"id0": true,
|
"id0": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -13937,6 +13983,7 @@ exports[`regression tests > switches from group of selected elements to another
|
|||||||
"id6": true,
|
"id6": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -14277,6 +14324,7 @@ exports[`regression tests > switches selected element on pointer down > [end of
|
|||||||
"id3": true,
|
"id3": true,
|
||||||
},
|
},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -14541,6 +14589,7 @@ exports[`regression tests > two-finger scroll works > [end of test] appState 1`]
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 20,
|
"scrollX": 20,
|
||||||
"scrollY": "-18.53553",
|
"scrollY": "-18.53553",
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -14666,6 +14715,7 @@ exports[`regression tests > undo/redo drawing an element > [end of test] appStat
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -15060,6 +15110,7 @@ exports[`regression tests > updates fontSize & fontFamily appState > [end of tes
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
@@ -15188,6 +15239,7 @@ exports[`regression tests > zoom hotkeys > [end of test] appState 1`] = `
|
|||||||
},
|
},
|
||||||
"previousSelectedElementIds": {},
|
"previousSelectedElementIds": {},
|
||||||
"resizingElement": null,
|
"resizingElement": null,
|
||||||
|
"scrollConstraints": null,
|
||||||
"scrollX": 0,
|
"scrollX": 0,
|
||||||
"scrollY": 0,
|
"scrollY": 0,
|
||||||
"scrolledOutside": false,
|
"scrolledOutside": false,
|
||||||
|
|||||||
@@ -100,12 +100,18 @@ describe("contextMenu element", () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
expect(contextMenu).not.toBeNull();
|
expect(contextMenu).not.toBeNull();
|
||||||
expect(contextMenuOptions?.length).toBe(expectedShortcutNames.length);
|
|
||||||
expectedShortcutNames.forEach((shortcutName) => {
|
expectedShortcutNames.forEach((shortcutName) => {
|
||||||
expect(
|
try {
|
||||||
contextMenu?.querySelector(`li[data-testid="${shortcutName}"]`),
|
expect(
|
||||||
).not.toBeNull();
|
contextMenu?.querySelector(`li[data-testid="${shortcutName}"]`),
|
||||||
|
).not.toBeNull();
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to find context menu item with test id: ${shortcutName}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
expect(contextMenuOptions?.length).toBe(expectedShortcutNames.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows context menu for element", () => {
|
it("shows context menu for element", () => {
|
||||||
|
|||||||
@@ -432,6 +432,7 @@ export interface AppState {
|
|||||||
userToFollow: UserToFollow | null;
|
userToFollow: UserToFollow | null;
|
||||||
/** the socket ids of the users following the current user */
|
/** the socket ids of the users following the current user */
|
||||||
followedBy: Set<SocketId>;
|
followedBy: Set<SocketId>;
|
||||||
|
scrollConstraints: ScrollConstraints | null;
|
||||||
|
|
||||||
/** image cropping */
|
/** image cropping */
|
||||||
isCropping: boolean;
|
isCropping: boolean;
|
||||||
@@ -617,6 +618,7 @@ export interface ExcalidrawProps {
|
|||||||
onScrollChange?: (scrollX: number, scrollY: number, zoom: Zoom) => void;
|
onScrollChange?: (scrollX: number, scrollY: number, zoom: Zoom) => void;
|
||||||
onUserFollow?: (payload: OnUserFollowedPayload) => void;
|
onUserFollow?: (payload: OnUserFollowedPayload) => void;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
|
scrollConstraints?: AppState["scrollConstraints"];
|
||||||
validateEmbeddable?:
|
validateEmbeddable?:
|
||||||
| boolean
|
| boolean
|
||||||
| string[]
|
| string[]
|
||||||
@@ -888,6 +890,7 @@ export interface ExcalidrawImperativeAPI {
|
|||||||
onUserFollow: (
|
onUserFollow: (
|
||||||
callback: (payload: OnUserFollowedPayload) => void,
|
callback: (payload: OnUserFollowedPayload) => void,
|
||||||
) => UnsubscribeCallback;
|
) => UnsubscribeCallback;
|
||||||
|
setScrollConstraints: InstanceType<typeof App>["setScrollConstraints"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FrameNameBounds = {
|
export type FrameNameBounds = {
|
||||||
@@ -911,6 +914,12 @@ export type FrameNameBoundsCache = {
|
|||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type AnimateTranslateCanvasValues = {
|
||||||
|
scrollX: AppState["scrollX"];
|
||||||
|
scrollY: AppState["scrollY"];
|
||||||
|
zoom: AppState["zoom"]["value"];
|
||||||
|
};
|
||||||
|
|
||||||
export type KeyboardModifiersObject = {
|
export type KeyboardModifiersObject = {
|
||||||
ctrlKey: boolean;
|
ctrlKey: boolean;
|
||||||
shiftKey: boolean;
|
shiftKey: boolean;
|
||||||
@@ -936,6 +945,29 @@ export type EmbedsValidationStatus = Map<
|
|||||||
|
|
||||||
export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
|
export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
|
||||||
|
|
||||||
|
export type ScrollConstraints = {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
animateOnNextUpdate?: boolean;
|
||||||
|
/**
|
||||||
|
* a facotr <0-1> that determines how much you can zoom out beyond the scroll
|
||||||
|
* constraints.
|
||||||
|
*/
|
||||||
|
viewportZoomFactor?: number;
|
||||||
|
/**
|
||||||
|
* If true, the user will not be able to zoom out beyond the scroll
|
||||||
|
* constraints (taking into account the viewportZoomFactor).
|
||||||
|
*/
|
||||||
|
lockZoom?: boolean;
|
||||||
|
/**
|
||||||
|
* <0-1> - how much can you scroll beyond the constrained area within the
|
||||||
|
* timeout window. Note you will still be snapped back to the constrained area
|
||||||
|
* after the timeout.
|
||||||
|
*/
|
||||||
|
overscrollAllowance?: number;
|
||||||
|
};
|
||||||
export type PendingExcalidrawElements = ExcalidrawElement[];
|
export type PendingExcalidrawElements = ExcalidrawElement[];
|
||||||
|
|
||||||
/** Runtime gridSize value. Null indicates disabled grid. */
|
/** Runtime gridSize value. Null indicates disabled grid. */
|
||||||
|
|||||||
@@ -54,7 +54,14 @@ export const exportToCanvas = ({
|
|||||||
const { exportBackground, viewBackgroundColor } = restoredAppState;
|
const { exportBackground, viewBackgroundColor } = restoredAppState;
|
||||||
return _exportToCanvas(
|
return _exportToCanvas(
|
||||||
restoredElements,
|
restoredElements,
|
||||||
{ ...restoredAppState, offsetTop: 0, offsetLeft: 0, width: 0, height: 0 },
|
{
|
||||||
|
...restoredAppState,
|
||||||
|
offsetTop: 0,
|
||||||
|
offsetLeft: 0,
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
scrollConstraints: null,
|
||||||
|
},
|
||||||
files || {},
|
files || {},
|
||||||
{ exportBackground, exportPadding, viewBackgroundColor, exportingFrame },
|
{ exportBackground, exportPadding, viewBackgroundColor, exportingFrame },
|
||||||
(width: number, height: number) => {
|
(width: number, height: number) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user