Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/composables/maskeditor/usePanAndZoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,19 @@ export function usePanAndZoom() {
}
)

const addPenPointerId = (pointerId: number): void => {
if (!penPointerIdList.value.includes(pointerId)) {
penPointerIdList.value.push(pointerId)
}
}

const removePenPointerId = (pointerId: number): void => {
const index = penPointerIdList.value.indexOf(pointerId)
if (index !== -1) {
penPointerIdList.value.splice(index, 1)
}
}

return {
initializeCanvasPanZoom,
handlePanStart,
Expand All @@ -411,6 +424,8 @@ export function usePanAndZoom() {
handleTouchEnd,
updateCursorPosition,
zoom,
invalidatePanZoom
invalidatePanZoom,
addPenPointerId,
removePenPointerId
}
}
9 changes: 9 additions & 0 deletions src/composables/maskeditor/useToolManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export function useToolManager(
event.preventDefault()
if (event.pointerType === 'touch') return

if (event.pointerType === 'pen') {
panZoom.addPenPointerId(event.pointerId)
}

const isSpacePressed = keyboard.isKeyDown(' ')

if (event.buttons === 4 || (event.buttons === 1 && isSpacePressed)) {
Expand Down Expand Up @@ -207,6 +211,11 @@ export function useToolManager(
const handlePointerUp = async (event: PointerEvent): Promise<void> => {
store.isPanning = false
store.brushVisible = true

if (event.pointerType === 'pen') {
panZoom.removePenPointerId(event.pointerId)
}

if (event.pointerType === 'touch') return
updateCursor()
store.isAdjustingBrush = false
Expand Down