Skip to content

Commit

Permalink
fix(mind): use current x,y to create mind cause can not point by getM…
Browse files Browse the repository at this point in the history
…ovingPointInBoard on mobile

plait-board/drawnix#20
  • Loading branch information
pubuzhixing8 committed Nov 8, 2024
1 parent be2bbf4 commit 26f77e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .changeset/bright-flies-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@plait/mind': minor
---

use current x,y to create mind cause user can not get point by getMovingPointInBoard on mobile

On touchscreens, users need to first touch the screen and then move their finger to trigger the pointermove event.

https://github.com/plait-board/drawnix/issues/20
7 changes: 3 additions & 4 deletions packages/mind/src/plugins/with-mind-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ export const withCreateMind = (board: PlaitBoard) => {

newBoard.pointerDown = (event: PointerEvent) => {
const isMindPointer = PlaitBoard.isPointer<MindPointerType | PlaitPointerType>(board, MindPointerType.mind);
let movingPoint = PlaitBoard.getMovingPointInBoard(board);
if (!PlaitBoard.isReadonly(board) && movingPoint && isDrawingMode(board) && isMindPointer) {
movingPoint = toViewBoxPoint(board, toHostPoint(board, movingPoint[0], movingPoint[1]));
const emptyMind = createEmptyMind(newBoard, movingPoint);
if (!PlaitBoard.isReadonly(board) && isDrawingMode(board) && isMindPointer) {
const point = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
const emptyMind = createEmptyMind(newBoard, point);
MindTransforms.insertMind(board as PlaitMindBoard, emptyMind);
BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
return;
Expand Down

0 comments on commit 26f77e3

Please sign in to comment.