@zsviczian/excalidraw 0.15.2-obsidian-5 → 0.15.2-obsidian-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/excalidraw.development.js +49 -27
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +1 -1
- package/types/actions/actionAddToLibrary.d.ts +12 -12
- package/types/actions/actionBoundText.d.ts +6 -5
- package/types/actions/actionCanvas.d.ts +337 -41
- package/types/actions/actionClipboard.d.ts +17 -17
- package/types/actions/actionDeleteSelected.d.ts +9 -9
- package/types/actions/actionElementLock.d.ts +5 -5
- package/types/actions/actionExport.d.ts +36 -36
- package/types/actions/actionFinalize.d.ts +8 -8
- package/types/actions/actionFrame.d.ts +9 -9
- package/types/actions/actionLinearEditor.d.ts +4 -4
- package/types/actions/actionMenu.d.ts +12 -12
- package/types/actions/actionProperties.d.ts +52 -52
- package/types/actions/actionStyles.d.ts +4 -4
- package/types/actions/actionToggleGridMode.d.ts +4 -4
- package/types/actions/actionToggleStats.d.ts +4 -4
- package/types/actions/actionToggleViewMode.d.ts +4 -4
- package/types/actions/actionToggleZenMode.d.ts +4 -4
- package/types/actions/types.d.ts +1 -1
- package/types/appState.d.ts +4 -4
- package/types/components/App.d.ts +13 -1
- package/types/constants.d.ts +8 -8
- package/types/data/url.d.ts +2 -0
- package/types/element/Hyperlink.d.ts +4 -6
- package/types/element/iframe.d.ts +5 -11
- package/types/element/linearElementEditor.d.ts +4 -4
- package/types/element/newElement.d.ts +1 -2
- package/types/element/types.d.ts +8 -1
- package/types/groups.d.ts +1 -1
- package/types/history.d.ts +3 -3
- package/types/keys.d.ts +1 -0
- package/types/packages/excalidraw/index.d.ts +1 -0
- package/types/scene/selection.d.ts +11 -1
- package/types/types.d.ts +9 -5
- package/types/utils.d.ts +41 -14
package/types/actions/types.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type ActionResult = {
|
|
|
15
15
|
type ActionFn = (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, formData: any, app: AppClassProperties) => ActionResult | Promise<ActionResult>;
|
|
16
16
|
export type UpdaterFn = (res: ActionResult) => void;
|
|
17
17
|
export type ActionFilterFn = (action: Action) => void;
|
|
18
|
-
export type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "copyText" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "zenMode" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeStrokeShape" | "changeSloppiness" | "changeStrokeStyle" | "changeArrowhead" | "changeOpacity" | "changeFontSize" | "toggleCanvasMenu" | "toggleEditMenu" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "clearCanvas" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "
|
|
18
|
+
export type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "copyText" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "zenMode" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeStrokeShape" | "changeSloppiness" | "changeStrokeStyle" | "changeArrowhead" | "changeOpacity" | "changeFontSize" | "toggleCanvasMenu" | "toggleEditMenu" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "clearCanvas" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "zoomToFitSelection" | "zoomToFitSelectionInViewport" | "changeFontFamily" | "changeTextAlign" | "changeVerticalAlign" | "toggleFullScreen" | "toggleShortcuts" | "group" | "ungroup" | "goToCollaborator" | "addToLibrary" | "changeRoundness" | "alignTop" | "alignBottom" | "alignLeft" | "alignRight" | "alignVerticallyCentered" | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" | "flipHorizontal" | "flipVertical" | "viewMode" | "exportWithDarkMode" | "toggleTheme" | "increaseFontSize" | "decreaseFontSize" | "unbindText" | "hyperlink" | "bindText" | "unlockAllElements" | "toggleElementLock" | "toggleLinearEditor" | "toggleEraserTool" | "toggleHandTool" | "selectAllElementsInFrame" | "removeAllElementsFromFrame" | "toggleFrameRendering" | "setFrameAsActiveTool" | "setIFrameAsActiveTool" | "createContainerFromText" | "wrapTextInContainer";
|
|
19
19
|
export type PanelComponentProps = {
|
|
20
20
|
elements: readonly ExcalidrawElement[];
|
|
21
21
|
appState: AppState;
|
package/types/appState.d.ts
CHANGED
|
@@ -48,11 +48,11 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
|
|
|
48
48
|
} | null | undefined;
|
|
49
49
|
defaultSidebarDockedPreference?: boolean | undefined;
|
|
50
50
|
lastPointerDownWith?: import("./element/types").PointerType | undefined;
|
|
51
|
-
selectedElementIds?: {
|
|
52
|
-
[id: string]:
|
|
53
|
-
} | undefined;
|
|
51
|
+
selectedElementIds?: Readonly<{
|
|
52
|
+
[id: string]: true;
|
|
53
|
+
}> | undefined;
|
|
54
54
|
previousSelectedElementIds?: {
|
|
55
|
-
[id: string]:
|
|
55
|
+
[id: string]: true;
|
|
56
56
|
} | undefined;
|
|
57
57
|
shouldCacheIgnoreZoom?: boolean | undefined;
|
|
58
58
|
zenModeEnabled?: boolean | undefined;
|
|
@@ -52,6 +52,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
52
52
|
private excalidrawContainerValue;
|
|
53
53
|
files: BinaryFiles;
|
|
54
54
|
imageCache: AppClassProperties["imageCache"];
|
|
55
|
+
private iFrameRefs;
|
|
55
56
|
hitLinkElement?: NonDeletedExcalidrawElement;
|
|
56
57
|
lastPointerDown: React.PointerEvent<HTMLElement> | null;
|
|
57
58
|
lastPointerUp: React.PointerEvent<HTMLElement> | PointerEvent | null;
|
|
@@ -59,7 +60,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
59
60
|
x: number;
|
|
60
61
|
y: number;
|
|
61
62
|
};
|
|
62
|
-
private iFrameRefs;
|
|
63
63
|
allowMobileMode: boolean;
|
|
64
64
|
constructor(props: AppProps);
|
|
65
65
|
private renderCanvas;
|
|
@@ -68,6 +68,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
68
68
|
private getIFrameElementById;
|
|
69
69
|
private handleIFrameCenterClick;
|
|
70
70
|
private isIFrameCenter;
|
|
71
|
+
private updateIFrames;
|
|
71
72
|
private renderIFrames;
|
|
72
73
|
private getFrameNameDOMId;
|
|
73
74
|
frameNameBoundsCache: FrameNameBoundsCache;
|
|
@@ -122,6 +123,17 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
122
123
|
private cancelInProgresAnimation;
|
|
123
124
|
scrollToContent: (target?: ExcalidrawElement | readonly ExcalidrawElement[], opts?: {
|
|
124
125
|
fitToContent?: boolean;
|
|
126
|
+
fitToViewport?: never;
|
|
127
|
+
viewportZoomFactor?: never;
|
|
128
|
+
animate?: boolean;
|
|
129
|
+
duration?: number;
|
|
130
|
+
} | {
|
|
131
|
+
fitToContent?: never;
|
|
132
|
+
fitToViewport?: boolean;
|
|
133
|
+
/** when fitToViewport=true, how much screen should the content cover,
|
|
134
|
+
* between 0.1 (10%) and 1 (100%)
|
|
135
|
+
*/
|
|
136
|
+
viewportZoomFactor?: number;
|
|
125
137
|
animate?: boolean;
|
|
126
138
|
duration?: number;
|
|
127
139
|
}) => void;
|
package/types/constants.d.ts
CHANGED
|
@@ -60,14 +60,14 @@ export declare enum EVENT {
|
|
|
60
60
|
MENU_ITEM_SELECT = "menu.itemSelect",
|
|
61
61
|
MESSAGE = "message"
|
|
62
62
|
}
|
|
63
|
-
export declare
|
|
64
|
-
UNSTARTED
|
|
65
|
-
ENDED
|
|
66
|
-
PLAYING
|
|
67
|
-
PAUSED
|
|
68
|
-
BUFFERING
|
|
69
|
-
CUED
|
|
70
|
-
}
|
|
63
|
+
export declare const YOUTUBE_STATES: {
|
|
64
|
+
readonly UNSTARTED: -1;
|
|
65
|
+
readonly ENDED: 0;
|
|
66
|
+
readonly PLAYING: 1;
|
|
67
|
+
readonly PAUSED: 2;
|
|
68
|
+
readonly BUFFERING: 3;
|
|
69
|
+
readonly CUED: 5;
|
|
70
|
+
};
|
|
71
71
|
export declare const ENV: {
|
|
72
72
|
TEST: string;
|
|
73
73
|
DEVELOPMENT: string;
|
|
@@ -14,8 +14,6 @@ export declare const Hyperlink: ({ element, setAppState, onLinkOpen, setToast, }
|
|
|
14
14
|
duration?: number;
|
|
15
15
|
} | null) => void;
|
|
16
16
|
}) => JSX.Element | null;
|
|
17
|
-
export declare const normalizeLink: (link: string) => string;
|
|
18
|
-
export declare const isLocalLink: (link: string | null | undefined) => boolean;
|
|
19
17
|
export declare const actionLink: {
|
|
20
18
|
name: "hyperlink";
|
|
21
19
|
perform: (elements: readonly import("./types").ExcalidrawElement[], appState: Readonly<AppState>) => false | {
|
|
@@ -96,11 +94,11 @@ export declare const actionLink: {
|
|
|
96
94
|
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
97
95
|
defaultSidebarDockedPreference: boolean;
|
|
98
96
|
lastPointerDownWith: import("./types").PointerType;
|
|
99
|
-
selectedElementIds: {
|
|
100
|
-
[id: string]:
|
|
101
|
-
}
|
|
97
|
+
selectedElementIds: Readonly<{
|
|
98
|
+
[id: string]: true;
|
|
99
|
+
}>;
|
|
102
100
|
previousSelectedElementIds: {
|
|
103
|
-
[id: string]:
|
|
101
|
+
[id: string]: true;
|
|
104
102
|
};
|
|
105
103
|
selectedElementsAreBeingDragged: boolean;
|
|
106
104
|
shouldCacheIgnoreZoom: boolean;
|
|
@@ -95,11 +95,11 @@ export declare const actionSetIFrameAsActiveTool: {
|
|
|
95
95
|
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
96
96
|
defaultSidebarDockedPreference: boolean;
|
|
97
97
|
lastPointerDownWith: import("./types").PointerType;
|
|
98
|
-
selectedElementIds: {
|
|
99
|
-
[id: string]:
|
|
100
|
-
}
|
|
98
|
+
selectedElementIds: Readonly<{
|
|
99
|
+
[id: string]: true;
|
|
100
|
+
}>;
|
|
101
101
|
previousSelectedElementIds: {
|
|
102
|
-
[id: string]:
|
|
102
|
+
[id: string]: true;
|
|
103
103
|
};
|
|
104
104
|
selectedElementsAreBeingDragged: boolean;
|
|
105
105
|
shouldCacheIgnoreZoom: boolean;
|
|
@@ -163,11 +163,5 @@ export declare const actionSetIFrameAsActiveTool: {
|
|
|
163
163
|
} & {
|
|
164
164
|
keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
|
|
165
165
|
};
|
|
166
|
-
export declare
|
|
167
|
-
private static instance;
|
|
168
|
-
private validators;
|
|
169
|
-
private constructor();
|
|
170
|
-
static getInstance(validators?: RegExp[]): IFrameURLValidator;
|
|
171
|
-
run(url: string | null | undefined): boolean;
|
|
172
|
-
}
|
|
166
|
+
export declare const iframeURLValidator: (url: string | null | undefined, validateIFrame: ExcalidrawProps["validateIFrame"]) => boolean;
|
|
173
167
|
export {};
|
|
@@ -196,11 +196,11 @@ export declare class LinearElementEditor {
|
|
|
196
196
|
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
197
197
|
defaultSidebarDockedPreference: boolean;
|
|
198
198
|
lastPointerDownWith: import("./types").PointerType;
|
|
199
|
-
selectedElementIds: {
|
|
200
|
-
[id: string]:
|
|
201
|
-
}
|
|
199
|
+
selectedElementIds: Readonly<{
|
|
200
|
+
[id: string]: true;
|
|
201
|
+
}>;
|
|
202
202
|
previousSelectedElementIds: {
|
|
203
|
-
[id: string]:
|
|
203
|
+
[id: string]: true;
|
|
204
204
|
};
|
|
205
205
|
selectedElementsAreBeingDragged: boolean;
|
|
206
206
|
shouldCacheIgnoreZoom: boolean;
|
|
@@ -7,7 +7,7 @@ export declare const newElement: (opts: {
|
|
|
7
7
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawGenericElement>;
|
|
8
8
|
export declare const newIFrameElement: (opts: {
|
|
9
9
|
type: "iframe";
|
|
10
|
-
|
|
10
|
+
validated: boolean | undefined;
|
|
11
11
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawIFrameElement>;
|
|
12
12
|
export declare const newFrameElement: (opts: ElementConstructorOpts) => NonDeleted<ExcalidrawFrameElement>;
|
|
13
13
|
export declare const newTextElement: (opts: {
|
|
@@ -20,7 +20,6 @@ export declare const newTextElement: (opts: {
|
|
|
20
20
|
containerId?: ExcalidrawTextContainer["id"];
|
|
21
21
|
lineHeight?: ExcalidrawTextElement["lineHeight"];
|
|
22
22
|
strokeWidth?: ExcalidrawTextElement["strokeWidth"];
|
|
23
|
-
isFrameName?: boolean;
|
|
24
23
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
|
|
25
24
|
export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
|
|
26
25
|
x: number;
|
package/types/element/types.d.ts
CHANGED
|
@@ -74,7 +74,14 @@ export type ExcalidrawEllipseElement = _ExcalidrawElementBase & {
|
|
|
74
74
|
type: "ellipse";
|
|
75
75
|
};
|
|
76
76
|
export type ExcalidrawIFrameElement = _ExcalidrawElementBase & Readonly<{
|
|
77
|
-
|
|
77
|
+
/**
|
|
78
|
+
* indicates whether the iframe src (url) has been validated for rendering.
|
|
79
|
+
* nullish value indicates that the validation is pending. We reset the
|
|
80
|
+
* value on each restore (or url change) so that we can guarantee
|
|
81
|
+
* the validation came from a trusted source (the editor). Also because we
|
|
82
|
+
* may not have access to host-app supplied url validator during restore.
|
|
83
|
+
*/
|
|
84
|
+
validated?: boolean;
|
|
78
85
|
type: "iframe";
|
|
79
86
|
}>;
|
|
80
87
|
export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
|
package/types/groups.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const getSelectedGroupIds: (appState: AppState) => GroupId[];
|
|
|
12
12
|
* When you select an element, you often want to actually select the whole group it's in, unless
|
|
13
13
|
* you're currently editing that group.
|
|
14
14
|
*/
|
|
15
|
-
export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => AppState;
|
|
15
|
+
export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[], prevAppState: AppState) => AppState;
|
|
16
16
|
export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: AppState) => {
|
|
17
17
|
[groupId: string]: boolean;
|
|
18
18
|
};
|
package/types/history.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ export interface HistoryEntry {
|
|
|
5
5
|
elements: ExcalidrawElement[];
|
|
6
6
|
}
|
|
7
7
|
declare const clearAppStatePropertiesForHistory: (appState: AppState) => {
|
|
8
|
-
selectedElementIds: {
|
|
9
|
-
[id: string]:
|
|
10
|
-
}
|
|
8
|
+
selectedElementIds: Readonly<{
|
|
9
|
+
[id: string]: true;
|
|
10
|
+
}>;
|
|
11
11
|
selectedGroupIds: {
|
|
12
12
|
[groupId: string]: boolean;
|
|
13
13
|
};
|
package/types/keys.d.ts
CHANGED
|
@@ -8,7 +8,10 @@ import { AppState } from "../types";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const excludeElementsInFramesFromSelection: <T extends ExcalidrawElement>(selectedElements: readonly T[]) => T[];
|
|
10
10
|
export declare const getElementsWithinSelection: (elements: readonly NonDeletedExcalidrawElement[], selection: NonDeletedExcalidrawElement, excludeElementsInFrames?: boolean) => NonDeletedExcalidrawElement[];
|
|
11
|
-
export declare const isSomeElementSelected:
|
|
11
|
+
export declare const isSomeElementSelected: {
|
|
12
|
+
(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">): boolean;
|
|
13
|
+
clearCache(): void;
|
|
14
|
+
};
|
|
12
15
|
/**
|
|
13
16
|
* Returns common attribute (picked by `getAttribute` callback) of selected
|
|
14
17
|
* elements. If elements don't share the same value, returns `null`.
|
|
@@ -19,3 +22,10 @@ export declare const getSelectedElements: (elements: readonly NonDeletedExcalidr
|
|
|
19
22
|
includeElementsInFrames?: boolean;
|
|
20
23
|
}) => ExcalidrawElement[];
|
|
21
24
|
export declare const getTargetElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds" | "editingElement">) => ExcalidrawElement[];
|
|
25
|
+
/**
|
|
26
|
+
* returns prevState's selectedElementids if no change from previous, so as to
|
|
27
|
+
* retain reference identity for memoization
|
|
28
|
+
*/
|
|
29
|
+
export declare const makeNextSelectedElementIds: (nextSelectedElementIds: AppState["selectedElementIds"], prevState: Pick<AppState, "selectedElementIds">) => Readonly<{
|
|
30
|
+
[id: string]: true;
|
|
31
|
+
}>;
|
package/types/types.d.ts
CHANGED
|
@@ -150,11 +150,11 @@ export type AppState = {
|
|
|
150
150
|
*/
|
|
151
151
|
defaultSidebarDockedPreference: boolean;
|
|
152
152
|
lastPointerDownWith: PointerType;
|
|
153
|
-
selectedElementIds: {
|
|
154
|
-
[id: string]:
|
|
155
|
-
}
|
|
153
|
+
selectedElementIds: Readonly<{
|
|
154
|
+
[id: string]: true;
|
|
155
|
+
}>;
|
|
156
156
|
previousSelectedElementIds: {
|
|
157
|
-
[id: string]:
|
|
157
|
+
[id: string]: true;
|
|
158
158
|
};
|
|
159
159
|
selectedElementsAreBeingDragged: boolean;
|
|
160
160
|
shouldCacheIgnoreZoom: boolean;
|
|
@@ -306,8 +306,11 @@ export interface ExcalidrawProps {
|
|
|
306
306
|
onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
|
|
307
307
|
onScrollChange?: (scrollX: number, scrollY: number) => void;
|
|
308
308
|
children?: React.ReactNode;
|
|
309
|
-
|
|
309
|
+
validateIFrame?: boolean | RegExp | RegExp[] | ((link: string) => boolean | undefined);
|
|
310
310
|
renderCustomIFrame?: (element: NonDeletedExcalidrawElement, radius: number, appState: UIAppState) => JSX.Element | null;
|
|
311
|
+
renderWebview?: boolean;
|
|
312
|
+
renderIFrameMenu?: (//zsivzian
|
|
313
|
+
appState: AppState) => JSX.Element | null;
|
|
311
314
|
}
|
|
312
315
|
export type SceneData = {
|
|
313
316
|
elements?: ImportedDataState["elements"];
|
|
@@ -463,6 +466,7 @@ export type ExcalidrawImperativeAPI = {
|
|
|
463
466
|
setCursor: InstanceType<typeof App>["setCursor"];
|
|
464
467
|
resetCursor: InstanceType<typeof App>["resetCursor"];
|
|
465
468
|
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
469
|
+
getIFrameElementById: InstanceType<typeof App>["getIFrameElementById"];
|
|
466
470
|
/**
|
|
467
471
|
* Disables rendering of frames (including element clipping), but currently
|
|
468
472
|
* the frames are still interactive in edit mode. As such, this API should be
|
package/types/utils.d.ts
CHANGED
|
@@ -30,25 +30,52 @@ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void, op
|
|
|
30
30
|
cancel(): void;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
* callback through a requestAnimationFrame call
|
|
33
|
+
* Exponential ease-out method
|
|
35
34
|
*
|
|
36
|
-
*
|
|
35
|
+
* @param {number} k - The value to be tweened.
|
|
36
|
+
* @returns {number} The tweened value.
|
|
37
|
+
*/
|
|
38
|
+
export declare const easeOut: (k: number) => number;
|
|
39
|
+
/**
|
|
40
|
+
* Animates values from `fromValues` to `toValues` using the requestAnimationFrame API.
|
|
41
|
+
* Executes the `onStep` callback on each step with the interpolated values.
|
|
42
|
+
* Returns a function that can be called to cancel the animation.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Example usage:
|
|
46
|
+
* const fromValues = { x: 0, y: 0 };
|
|
47
|
+
* const toValues = { x: 100, y: 200 };
|
|
48
|
+
* const onStep = ({x, y}) => {
|
|
49
|
+
* setState(x, y)
|
|
50
|
+
* };
|
|
51
|
+
* const onCancel = () => {
|
|
52
|
+
* console.log("Animation canceled");
|
|
53
|
+
* };
|
|
37
54
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
55
|
+
* const cancelAnimation = easeToValuesRAF({
|
|
56
|
+
* fromValues,
|
|
57
|
+
* toValues,
|
|
58
|
+
* onStep,
|
|
59
|
+
* onCancel,
|
|
60
|
+
* });
|
|
42
61
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @param callback The callback receiving the values
|
|
46
|
-
* @param opts default to 250ms duration and the easeOut function
|
|
62
|
+
* // To cancel the animation:
|
|
63
|
+
* cancelAnimation();
|
|
47
64
|
*/
|
|
48
|
-
export declare const easeToValuesRAF: (fromValues
|
|
65
|
+
export declare const easeToValuesRAF: <T extends Record<keyof T, number>, K extends keyof T>({ fromValues, toValues, onStep, duration, interpolateValue, onStart, onEnd, onCancel, }: {
|
|
66
|
+
fromValues: T;
|
|
67
|
+
toValues: T;
|
|
68
|
+
/**
|
|
69
|
+
* Interpolate a single value.
|
|
70
|
+
* Return undefined to be handled by the default interpolator.
|
|
71
|
+
*/
|
|
72
|
+
interpolateValue?: ((fromValue: number, toValue: number, progress: number, key: K) => number | undefined) | undefined;
|
|
73
|
+
onStep: (values: T) => void;
|
|
49
74
|
duration?: number | undefined;
|
|
50
|
-
|
|
51
|
-
|
|
75
|
+
onStart?: (() => void) | undefined;
|
|
76
|
+
onEnd?: (() => void) | undefined;
|
|
77
|
+
onCancel?: (() => void) | undefined;
|
|
78
|
+
}) => () => void;
|
|
52
79
|
export declare const chunk: <T extends unknown>(array: readonly T[], size: number) => T[][];
|
|
53
80
|
export declare const selectNode: (node: Element) => void;
|
|
54
81
|
export declare const removeSelection: () => void;
|