Broadcast mouse activity (#1175)
* broadcast mouse activity * move to same MOUSE_LOCATION event * remove key up handler * update tests * Fix border * refactor * rename activity to button Co-authored-by: Panayiotis Lipiridis <lipiridis@gmail.com>
This commit is contained in:
parent
23540eba4c
commit
b97520400a
@ -26,6 +26,7 @@ export function getDefaultAppState(): AppState {
|
|||||||
scrollY: 0 as FlooredNumber,
|
scrollY: 0 as FlooredNumber,
|
||||||
cursorX: 0,
|
cursorX: 0,
|
||||||
cursorY: 0,
|
cursorY: 0,
|
||||||
|
cursorButton: "up",
|
||||||
scrolledOutside: false,
|
scrolledOutside: false,
|
||||||
name: `excalidraw-${getDateTime()}`,
|
name: `excalidraw-${getDateTime()}`,
|
||||||
isCollaborating: false,
|
isCollaborating: false,
|
||||||
|
@ -441,6 +441,10 @@ export class App extends React.Component<any, AppState> {
|
|||||||
if (this.state.isCollaborating && !this.socket) {
|
if (this.state.isCollaborating && !this.socket) {
|
||||||
this.initializeSocketClient({ showLoadingState: true });
|
this.initializeSocketClient({ showLoadingState: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cursorButton: {
|
||||||
|
[id: string]: string | undefined;
|
||||||
|
} = {};
|
||||||
const pointerViewportCoords: SceneState["remotePointerViewportCoords"] = {};
|
const pointerViewportCoords: SceneState["remotePointerViewportCoords"] = {};
|
||||||
const remoteSelectedElementIds: SceneState["remoteSelectedElementIds"] = {};
|
const remoteSelectedElementIds: SceneState["remoteSelectedElementIds"] = {};
|
||||||
this.state.collaborators.forEach((user, socketID) => {
|
this.state.collaborators.forEach((user, socketID) => {
|
||||||
@ -464,6 +468,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
this.canvas,
|
this.canvas,
|
||||||
window.devicePixelRatio,
|
window.devicePixelRatio,
|
||||||
);
|
);
|
||||||
|
cursorButton[socketID] = user.button;
|
||||||
});
|
});
|
||||||
const { atLeastOneVisibleElement, scrollBars } = renderScene(
|
const { atLeastOneVisibleElement, scrollBars } = renderScene(
|
||||||
globalSceneState.getAllElements().filter((element) => {
|
globalSceneState.getAllElements().filter((element) => {
|
||||||
@ -486,6 +491,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
viewBackgroundColor: this.state.viewBackgroundColor,
|
viewBackgroundColor: this.state.viewBackgroundColor,
|
||||||
zoom: this.state.zoom,
|
zoom: this.state.zoom,
|
||||||
remotePointerViewportCoords: pointerViewportCoords,
|
remotePointerViewportCoords: pointerViewportCoords,
|
||||||
|
remotePointerButton: cursorButton,
|
||||||
remoteSelectedElementIds: remoteSelectedElementIds,
|
remoteSelectedElementIds: remoteSelectedElementIds,
|
||||||
shouldCacheIgnoreZoom: this.state.shouldCacheIgnoreZoom,
|
shouldCacheIgnoreZoom: this.state.shouldCacheIgnoreZoom,
|
||||||
},
|
},
|
||||||
@ -871,6 +877,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
const {
|
const {
|
||||||
socketID,
|
socketID,
|
||||||
pointerCoords,
|
pointerCoords,
|
||||||
|
button,
|
||||||
selectedElementIds,
|
selectedElementIds,
|
||||||
} = decryptedData.payload;
|
} = decryptedData.payload;
|
||||||
this.setState((state) => {
|
this.setState((state) => {
|
||||||
@ -879,6 +886,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
}
|
}
|
||||||
const user = state.collaborators.get(socketID)!;
|
const user = state.collaborators.get(socketID)!;
|
||||||
user.pointer = pointerCoords;
|
user.pointer = pointerCoords;
|
||||||
|
user.button = button;
|
||||||
user.selectedElementIds = selectedElementIds;
|
user.selectedElementIds = selectedElementIds;
|
||||||
state.collaborators.set(socketID, user);
|
state.collaborators.set(socketID, user);
|
||||||
return state;
|
return state;
|
||||||
@ -923,6 +931,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
|
|
||||||
private broadcastMouseLocation = (payload: {
|
private broadcastMouseLocation = (payload: {
|
||||||
pointerCoords: SocketUpdateDataSource["MOUSE_LOCATION"]["payload"]["pointerCoords"];
|
pointerCoords: SocketUpdateDataSource["MOUSE_LOCATION"]["payload"]["pointerCoords"];
|
||||||
|
button: SocketUpdateDataSource["MOUSE_LOCATION"]["payload"]["button"];
|
||||||
}) => {
|
}) => {
|
||||||
if (this.socket?.id) {
|
if (this.socket?.id) {
|
||||||
const data: SocketUpdateDataSource["MOUSE_LOCATION"] = {
|
const data: SocketUpdateDataSource["MOUSE_LOCATION"] = {
|
||||||
@ -930,6 +939,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
payload: {
|
payload: {
|
||||||
socketID: this.socket.id,
|
socketID: this.socket.id,
|
||||||
pointerCoords: payload.pointerCoords,
|
pointerCoords: payload.pointerCoords,
|
||||||
|
button: payload.button || "up",
|
||||||
selectedElementIds: this.state.selectedElementIds,
|
selectedElementIds: this.state.selectedElementIds,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -1345,13 +1355,8 @@ export class App extends React.Component<any, AppState> {
|
|||||||
private handleCanvasPointerMove = (
|
private handleCanvasPointerMove = (
|
||||||
event: React.PointerEvent<HTMLCanvasElement>,
|
event: React.PointerEvent<HTMLCanvasElement>,
|
||||||
) => {
|
) => {
|
||||||
const pointerCoords = viewportCoordsToSceneCoords(
|
this.savePointer(event.clientX, event.clientY, this.state.cursorButton);
|
||||||
event,
|
|
||||||
this.state,
|
|
||||||
this.canvas,
|
|
||||||
window.devicePixelRatio,
|
|
||||||
);
|
|
||||||
this.savePointer(pointerCoords);
|
|
||||||
if (gesture.pointers.has(event.pointerId)) {
|
if (gesture.pointers.has(event.pointerId)) {
|
||||||
gesture.pointers.set(event.pointerId, {
|
gesture.pointers.set(event.pointerId, {
|
||||||
x: event.clientX,
|
x: event.clientX,
|
||||||
@ -1502,7 +1507,11 @@ export class App extends React.Component<any, AppState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({ lastPointerDownWith: event.pointerType });
|
this.setState({
|
||||||
|
lastPointerDownWith: event.pointerType,
|
||||||
|
cursorButton: "down",
|
||||||
|
});
|
||||||
|
this.savePointer(event.clientX, event.clientY, "down");
|
||||||
|
|
||||||
// pan canvas on wheel button drag or space+drag
|
// pan canvas on wheel button drag or space+drag
|
||||||
if (
|
if (
|
||||||
@ -1535,6 +1544,10 @@ export class App extends React.Component<any, AppState> {
|
|||||||
if (!isHoldingSpace) {
|
if (!isHoldingSpace) {
|
||||||
setCursorForShape(this.state.elementType);
|
setCursorForShape(this.state.elementType);
|
||||||
}
|
}
|
||||||
|
this.setState({
|
||||||
|
cursorButton: "up",
|
||||||
|
});
|
||||||
|
this.savePointer(event.clientX, event.clientY, "up");
|
||||||
window.removeEventListener("pointermove", onPointerMove);
|
window.removeEventListener("pointermove", onPointerMove);
|
||||||
window.removeEventListener("pointerup", teardown);
|
window.removeEventListener("pointerup", teardown);
|
||||||
window.removeEventListener("blur", teardown);
|
window.removeEventListener("blur", teardown);
|
||||||
@ -1635,6 +1648,10 @@ export class App extends React.Component<any, AppState> {
|
|||||||
isDraggingScrollBar = false;
|
isDraggingScrollBar = false;
|
||||||
setCursorForShape(this.state.elementType);
|
setCursorForShape(this.state.elementType);
|
||||||
lastPointerUp = null;
|
lastPointerUp = null;
|
||||||
|
this.setState({
|
||||||
|
cursorButton: "up",
|
||||||
|
});
|
||||||
|
this.savePointer(event.clientX, event.clientY, "up");
|
||||||
window.removeEventListener("pointermove", onPointerMove);
|
window.removeEventListener("pointermove", onPointerMove);
|
||||||
window.removeEventListener("pointerup", onPointerUp);
|
window.removeEventListener("pointerup", onPointerUp);
|
||||||
});
|
});
|
||||||
@ -2398,7 +2415,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const onPointerUp = withBatchedUpdates((event: PointerEvent) => {
|
const onPointerUp = withBatchedUpdates((childEvent: PointerEvent) => {
|
||||||
const {
|
const {
|
||||||
draggingElement,
|
draggingElement,
|
||||||
resizingElement,
|
resizingElement,
|
||||||
@ -2412,11 +2429,15 @@ export class App extends React.Component<any, AppState> {
|
|||||||
isRotating: false,
|
isRotating: false,
|
||||||
resizingElement: null,
|
resizingElement: null,
|
||||||
selectionElement: null,
|
selectionElement: null,
|
||||||
|
cursorButton: "up",
|
||||||
editingElement: multiElement ? this.state.editingElement : null,
|
editingElement: multiElement ? this.state.editingElement : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.savePointer(childEvent.clientX, childEvent.clientY, "up");
|
||||||
|
|
||||||
resizeArrowFn = null;
|
resizeArrowFn = null;
|
||||||
lastPointerUp = null;
|
lastPointerUp = null;
|
||||||
|
|
||||||
window.removeEventListener("pointermove", onPointerMove);
|
window.removeEventListener("pointermove", onPointerMove);
|
||||||
window.removeEventListener("pointerup", onPointerUp);
|
window.removeEventListener("pointerup", onPointerUp);
|
||||||
|
|
||||||
@ -2426,7 +2447,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
}
|
}
|
||||||
if (!draggingOccurred && draggingElement && !multiElement) {
|
if (!draggingOccurred && draggingElement && !multiElement) {
|
||||||
const { x, y } = viewportCoordsToSceneCoords(
|
const { x, y } = viewportCoordsToSceneCoords(
|
||||||
event,
|
childEvent,
|
||||||
this.state,
|
this.state,
|
||||||
this.canvas,
|
this.canvas,
|
||||||
window.devicePixelRatio,
|
window.devicePixelRatio,
|
||||||
@ -2503,7 +2524,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
// was added to selection (on pointerdown phase) we need to keep
|
// was added to selection (on pointerdown phase) we need to keep
|
||||||
// selection unchanged
|
// selection unchanged
|
||||||
if (hitElement && !draggingOccurred && !hitElementWasAddedToSelection) {
|
if (hitElement && !draggingOccurred && !hitElementWasAddedToSelection) {
|
||||||
if (event.shiftKey) {
|
if (childEvent.shiftKey) {
|
||||||
this.setState((prevState) => ({
|
this.setState((prevState) => ({
|
||||||
selectedElementIds: {
|
selectedElementIds: {
|
||||||
...prevState.selectedElementIds,
|
...prevState.selectedElementIds,
|
||||||
@ -2735,12 +2756,26 @@ export class App extends React.Component<any, AppState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private savePointer = (pointerCoords: { x: number; y: number }) => {
|
private savePointer = (x: number, y: number, button: "up" | "down") => {
|
||||||
|
if (!x || !y) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const pointerCoords = viewportCoordsToSceneCoords(
|
||||||
|
{ clientX: x, clientY: y },
|
||||||
|
this.state,
|
||||||
|
this.canvas,
|
||||||
|
window.devicePixelRatio,
|
||||||
|
);
|
||||||
|
|
||||||
if (isNaN(pointerCoords.x) || isNaN(pointerCoords.y)) {
|
if (isNaN(pointerCoords.x) || isNaN(pointerCoords.y)) {
|
||||||
// sometimes the pointer goes off screen
|
// sometimes the pointer goes off screen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.socket && this.broadcastMouseLocation({ pointerCoords });
|
this.socket &&
|
||||||
|
this.broadcastMouseLocation({
|
||||||
|
pointerCoords,
|
||||||
|
button,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private resetShouldCacheIgnoreZoomDebounced = debounce(() => {
|
private resetShouldCacheIgnoreZoomDebounced = debounce(() => {
|
||||||
|
@ -49,6 +49,7 @@ export type SocketUpdateDataSource = {
|
|||||||
payload: {
|
payload: {
|
||||||
socketID: string;
|
socketID: string;
|
||||||
pointerCoords: { x: number; y: number };
|
pointerCoords: { x: number; y: number };
|
||||||
|
button: "down" | "up";
|
||||||
selectedElementIds: AppState["selectedElementIds"];
|
selectedElementIds: AppState["selectedElementIds"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -298,6 +298,26 @@ export function renderScene(
|
|||||||
if (isOutOfBounds) {
|
if (isOutOfBounds) {
|
||||||
context.globalAlpha = 0.2;
|
context.globalAlpha = 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
sceneState.remotePointerButton &&
|
||||||
|
sceneState.remotePointerButton[clientId] === "down"
|
||||||
|
) {
|
||||||
|
context.beginPath();
|
||||||
|
context.arc(x, y, 15, 0, 2 * Math.PI, false);
|
||||||
|
context.lineWidth = 3;
|
||||||
|
context.strokeStyle = "#ffffff88";
|
||||||
|
context.stroke();
|
||||||
|
context.closePath();
|
||||||
|
|
||||||
|
context.beginPath();
|
||||||
|
context.arc(x, y, 15, 0, 2 * Math.PI, false);
|
||||||
|
context.lineWidth = 1;
|
||||||
|
context.strokeStyle = stroke;
|
||||||
|
context.stroke();
|
||||||
|
context.closePath();
|
||||||
|
}
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.moveTo(x, y);
|
context.moveTo(x, y);
|
||||||
context.lineTo(x + 1, y + 14);
|
context.lineTo(x + 1, y + 14);
|
||||||
@ -309,6 +329,7 @@ export function renderScene(
|
|||||||
context.strokeStyle = strokeStyle;
|
context.strokeStyle = strokeStyle;
|
||||||
context.fillStyle = fillStyle;
|
context.fillStyle = fillStyle;
|
||||||
context.globalAlpha = globalAlpha;
|
context.globalAlpha = globalAlpha;
|
||||||
|
context.closePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paint scrollbars
|
// Paint scrollbars
|
||||||
|
@ -9,6 +9,7 @@ export type SceneState = {
|
|||||||
zoom: number;
|
zoom: number;
|
||||||
shouldCacheIgnoreZoom: boolean;
|
shouldCacheIgnoreZoom: boolean;
|
||||||
remotePointerViewportCoords: { [id: string]: { x: number; y: number } };
|
remotePointerViewportCoords: { [id: string]: { x: number; y: number } };
|
||||||
|
remotePointerButton?: { [id: string]: string | undefined };
|
||||||
remoteSelectedElementIds: { [elementId: string]: string[] };
|
remoteSelectedElementIds: { [elementId: string]: string[] };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -197,6 +198,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -307,6 +309,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#5f3dc4",
|
"currentItemStrokeColor": "#5f3dc4",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -557,6 +560,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -703,6 +707,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -885,6 +890,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -1072,6 +1078,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -1355,6 +1362,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -1951,6 +1959,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -2061,6 +2070,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -2171,6 +2181,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -2281,6 +2292,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -2413,6 +2425,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -2545,6 +2558,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -2677,6 +2691,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -2787,6 +2802,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -2897,6 +2913,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -3029,6 +3046,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -3139,6 +3157,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "down",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -3191,6 +3210,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -3877,6 +3897,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -4239,6 +4260,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -4529,6 +4551,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -4747,6 +4770,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -4893,6 +4917,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -5543,6 +5568,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -6121,6 +6147,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -6627,6 +6654,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -7061,6 +7089,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -7459,6 +7488,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -7785,6 +7815,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -8039,6 +8070,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -8221,6 +8253,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -8907,6 +8940,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -9521,6 +9555,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -10063,6 +10098,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -10533,6 +10569,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -10777,6 +10814,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -10815,7 +10853,7 @@ Object {
|
|||||||
|
|
||||||
exports[`regression tests spacebar + drag scrolls the canvas: [end of test] number of elements 1`] = `0`;
|
exports[`regression tests spacebar + drag scrolls the canvas: [end of test] number of elements 1`] = `0`;
|
||||||
|
|
||||||
exports[`regression tests spacebar + drag scrolls the canvas: [end of test] number of renders 1`] = `4`;
|
exports[`regression tests spacebar + drag scrolls the canvas: [end of test] number of renders 1`] = `5`;
|
||||||
|
|
||||||
exports[`regression tests two-finger scroll works: [end of test] appState 1`] = `
|
exports[`regression tests two-finger scroll works: [end of test] appState 1`] = `
|
||||||
Object {
|
Object {
|
||||||
@ -10827,6 +10865,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "down",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -10879,6 +10918,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
@ -11161,6 +11201,7 @@ Object {
|
|||||||
"currentItemRoughness": 1,
|
"currentItemRoughness": 1,
|
||||||
"currentItemStrokeColor": "#000000",
|
"currentItemStrokeColor": "#000000",
|
||||||
"currentItemStrokeWidth": 1,
|
"currentItemStrokeWidth": 1,
|
||||||
|
"cursorButton": "up",
|
||||||
"cursorX": 0,
|
"cursorX": 0,
|
||||||
"cursorY": 0,
|
"cursorY": 0,
|
||||||
"draggingElement": null,
|
"draggingElement": null,
|
||||||
|
@ -34,6 +34,7 @@ export type AppState = {
|
|||||||
scrollY: FlooredNumber;
|
scrollY: FlooredNumber;
|
||||||
cursorX: number;
|
cursorX: number;
|
||||||
cursorY: number;
|
cursorY: number;
|
||||||
|
cursorButton: "up" | "down";
|
||||||
scrolledOutside: boolean;
|
scrolledOutside: boolean;
|
||||||
name: string;
|
name: string;
|
||||||
isCollaborating: boolean;
|
isCollaborating: boolean;
|
||||||
@ -50,6 +51,7 @@ export type AppState = {
|
|||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
};
|
};
|
||||||
|
button?: "up" | "down";
|
||||||
selectedElementIds?: AppState["selectedElementIds"];
|
selectedElementIds?: AppState["selectedElementIds"];
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user