mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
* Don't reset cache while zooming using a gesture This reuses the cached canvas while the gesture is happening. Once it has stop updating, then recompute the cache with the proper zoom. This should massively improve performance when panning on big scenes on mobile Fixes #1056 * update snapshot tests
63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
import {
|
|
ExcalidrawElement,
|
|
PointerType,
|
|
ExcalidrawLinearElement,
|
|
} from "./element/types";
|
|
import { SHAPES } from "./shapes";
|
|
import { Point as RoughPoint } from "roughjs/bin/geometry";
|
|
|
|
export type FlooredNumber = number & { _brand: "FlooredNumber" };
|
|
export type Point = Readonly<RoughPoint>;
|
|
|
|
export type AppState = {
|
|
isLoading: boolean;
|
|
draggingElement: ExcalidrawElement | null;
|
|
resizingElement: ExcalidrawElement | null;
|
|
multiElement: ExcalidrawLinearElement | null;
|
|
selectionElement: ExcalidrawElement | null;
|
|
// element being edited, but not necessarily added to elements array yet
|
|
// (e.g. text element when typing into the input)
|
|
editingElement: ExcalidrawElement | null;
|
|
elementType: typeof SHAPES[number]["value"];
|
|
elementLocked: boolean;
|
|
exportBackground: boolean;
|
|
currentItemStrokeColor: string;
|
|
currentItemBackgroundColor: string;
|
|
currentItemFillStyle: string;
|
|
currentItemStrokeWidth: number;
|
|
currentItemRoughness: number;
|
|
currentItemOpacity: number;
|
|
currentItemFont: string;
|
|
viewBackgroundColor: string;
|
|
scrollX: FlooredNumber;
|
|
scrollY: FlooredNumber;
|
|
cursorX: number;
|
|
cursorY: number;
|
|
scrolledOutside: boolean;
|
|
name: string;
|
|
isCollaborating: boolean;
|
|
isResizing: boolean;
|
|
zoom: number;
|
|
openMenu: "canvas" | "shape" | null;
|
|
lastPointerDownWith: PointerType;
|
|
selectedElementIds: { [id: string]: boolean };
|
|
collaborators: Map<string, { pointer?: { x: number; y: number } }>;
|
|
shouldCacheIgnoreZoom: boolean;
|
|
};
|
|
|
|
export type PointerCoords = Readonly<{
|
|
x: number;
|
|
y: number;
|
|
}>;
|
|
|
|
export type Gesture = {
|
|
pointers: Map<number, PointerCoords>;
|
|
lastCenter: { x: number; y: number } | null;
|
|
initialDistance: number | null;
|
|
initialScale: number | null;
|
|
};
|
|
|
|
export declare class GestureEvent extends UIEvent {
|
|
readonly rotation: number;
|
|
readonly scale: number;
|
|
}
|