fix(tools): respect pan while painting
This commit is contained in:
@@ -62,16 +62,6 @@ export function useCanvasInput(
|
||||
|
||||
const handlePointerDown = (event: PointerEvent) => {
|
||||
const inputEvent = pointerInputEventFromPointerEvent(event);
|
||||
const state = store.getState();
|
||||
const brush = beginBrushSession(state.document, state.editor, viewportPointToDocumentPoint(inputEvent.position, state.editor.viewport));
|
||||
if (brush) {
|
||||
brushSessionId.current += 1;
|
||||
brushSession.current = brush;
|
||||
canvas.setPointerCapture(event.pointerId);
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
const transformed = transformHandler.pointerDown(inputEvent);
|
||||
if (transformed) {
|
||||
canvas.setPointerCapture(event.pointerId);
|
||||
@@ -87,6 +77,18 @@ export function useCanvasInput(
|
||||
return;
|
||||
}
|
||||
|
||||
const state = store.getState();
|
||||
const brush = (inputEvent.buttons & 1) === 1 && !isPanInteractionMode(state.editor.tools.interactionMode)
|
||||
? beginBrushSession(state.document, state.editor, viewportPointToDocumentPoint(inputEvent.position, state.editor.viewport))
|
||||
: undefined;
|
||||
if (brush) {
|
||||
brushSessionId.current += 1;
|
||||
brushSession.current = brush;
|
||||
canvas.setPointerCapture(event.pointerId);
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
const currentState = store.getState();
|
||||
const selectionToolActive = currentState.editor.tools.activeTool === "select" || currentState.editor.tools.activeTool === "crop";
|
||||
const selected = selectionToolActive && handleArtboardSelection({
|
||||
@@ -101,6 +103,13 @@ export function useCanvasInput(
|
||||
const handlePointerMove = (event: PointerEvent) => {
|
||||
const inputEvent = pointerInputEventFromPointerEvent(event);
|
||||
if (brushSession.current) {
|
||||
if ((inputEvent.buttons & 1) !== 1 || isPanInteractionMode(store.getState().editor.tools.interactionMode)) {
|
||||
brushSessionId.current += 1;
|
||||
brushSession.current = undefined;
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
const activeSessionId = brushSessionId.current;
|
||||
const point = viewportPointToDocumentPoint(inputEvent.position, store.getState().editor.viewport);
|
||||
const settings = store.getState().editor.tools.brush;
|
||||
|
||||
Reference in New Issue
Block a user