Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Apple Pencil Touch to Konva in Label Studio #1361

Closed
madhavajay opened this issue Jul 9, 2022 · 2 comments
Closed

Adding Apple Pencil Touch to Konva in Label Studio #1361

madhavajay opened this issue Jul 9, 2022 · 2 comments

Comments

@madhavajay
Copy link

Hi,
I am trying to add support for the apple pencil (using touch) in Brush annotation mode on the awesome Label Studio which uses Konva.
HumanSignal/label-studio#1982

I have debugged it using the frontend tooling they provide:
https://github.com/heartexlabs/label-studio-frontend

What I have discovered is that the normal ipad mouse (keyboard and track pad) does all the normal touch events fine, but when the touch or pencil triggers it seems to hit a preventDefault / stopPropagation type event.

IMG_87CE55CEB5A0-1

I saw mention in another issue that you can add events to the Stage element, however when I added some touch events that passed through the same functionality as mouse it doesn't work.
Screen Shot 2022-07-09 at 7 42 49 pm

I have also toyed with putting style="pointer-events: none; touch-action: none" on a higher div to prevent the internal scroll overflow from capturing the touch focus and then adding something like pointer events all or touch action auto on the div above the canvas, however I think I still mis-understand something about how this works.

Screen Shot 2022-07-09 at 7 44 26 pm

Do you have any ideas or suggestions on how I can suppress the x and y scroll on nested divs above the Konva Canvas and also enable the touch / pencil events to mirror the same as whats happening with the normal mouse?

I am both new to Konva and not very experienced with React or the Label Studio Frontend so im still trying to figure out which part is responsible for the issue, but it feels like its a combination:

  • touch events being captured by scrolling elements and page size too large
  • konva preventing the touch from registering
  • potentially some difference between touch and mouse which means I can't just map them 1:1
@lavrton
Copy link
Member

lavrton commented Jul 12, 2022

I usually just map all touch events into the same mouse handlers. E.g.:

<Stage
 onMouseDown={handleMouseDown}
 onTouchStart={handleMouseDown}
/>

And usually, it works good for me. Also, you can try to use pointer events.

@madhavajay
Copy link
Author

@lavrton sorry for the slow reply, I finally got to try, looks like I needed to use .layerX and .layerY as well and some other stuff: HumanSignal/label-studio-frontend#802

I guess that might be implementation details from label-studio-frontend rather than konvajs, although I would have imagined it would be nice if something like konva just handled touch vs mouse events internally.

@lavrton lavrton closed this as completed Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants