ngl
ngl copied to clipboard
Hoverpick event is fired only after a touchmove event is fired
Hi, when on a touchscreen I have the focus on an external element and than I try to hoverpick
inside the viewer, the event is not fired. To restore the behavior, I have to fire a touchmove
event before, and then the hoverpick
event is fired normally.
I don't quite understand, could you elaborate?
I noticed this behavior on mobile devices (iPad in particular) . For example consider default hoverpick event showing the tooltip when hovering over atoms. Now, if I have the focus on something different from the canvas, and I try to make a touch gesture to trigger the hoverpick event, the event isn't triggered. But instead, the hoverpick event is triggered if I touch+drag changing the view before.
Also the clickpick event is not fired at the same way
Is this specifically an NGL issue, or is this general behaviour with canvas objects when they lose focus?
Hi @fredludlow , I don't think so. I tried to set the focus on canvas with javascript before making the first touch gesture but the problem persists. Also this happens not only the first time I make the touch gesture, but it keeps happening until a touch+drag event is fired.
Testing with my browser's mobile emulation, I can reproduce this. The hover events only get fired on a touch move, not the initial touch, and the click pick is never fired. This matches exactly what I see in the code - only the _onTouchmove
function fires the moved and dragged signals which are responsible for initiating the hover pick (for mouse it makes sense to only do this on move, as it's a hover action), and the _onTouchend function fires no events.
This raises a question though: On a mobile device, which has no hover behavior, how should this work? Only fire the click event? Or maybe fire the hover event if it's a long-press but click if it's a short press? I've seen the latter, though I've also seen a long press equate to a right click.
I'd like to make a PR to address this, any thoughts?
I opt for a long press to fire the hover event. It seems more intuitive to me.