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

touchmove, touchmove.prevent, touchstart events don't report X/Y coordinates for ui components #3965

Open
aabrodskiy opened this issue Nov 8, 2024 · 2 comments

Comments

@aabrodskiy
Copy link

Description

While trying to implement mobile drag/drop behaviour, I ran into the fact that neither of touch events report ClientX/Y or pageX/Y into the GenericEventArguments structure, unlike the normal drag events.
Is this a simple bug that's easy to fix, or is it some sort of limitation of the framework?

@aabrodskiy
Copy link
Author

aabrodskiy commented Nov 8, 2024

By trial and error I found that "pointer" group of events produces all Xs and Ys while moving, so ended up implementing those handlers and it works just fine.

      .on('pointerdown', lambda e, c=col: self.handle_drag_start(e, c))\
      .on('pointerup', lambda e, c=col: self.handle_drop(e, c))\
      .on('pointermove.prevent', throttle=0.2, handler=lambda e: self.handle_pointer_move_prevent(e)):

in pointermove handler, it's important to check if it's indeed coming from the touch actions, or just normal mouse moving:

    async def handle_pointer_move_prevent(self, event):
        type = event.args.get('type')
        pointer_type = event.args.get('pointerType')
        if type == 'pointermove' and pointer_type == 'touch':
            #your logic goes here
@falkoschindler
Copy link
Contributor

Hi @aabrodskiy,

I'm not aware of a specific limitation for touch event arguments. Maybe you can share your code so that we can try to reproduce the problem more easily?

You mention you're implementing a mobile interface. Maybe it's a limitation of Safari. They don't seem to support touch events: https://developer.mozilla.org/en-US/docs/Web/API/Touch_events#browser_compatibility. So maybe pointer events are the better option anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants