rive-react icon indicating copy to clipboard operation
rive-react copied to clipboard

OnClick and scrolling not working on touch on mobile browsers

Open flogst opened this issue 2 years ago • 8 comments

The changes added in 3.0.40 remove the ability to handle onClick events on a React Canvas on mobile browsers. Scrolling on touch is also not working as expected.

To reproduce, I created two examples.

On version 3.0.39 everything is working as expected: https://codesandbox.io/s/rive-react-canvas-3-0-39-hdlvx4?file=/src/App.js

On version 3.0.40, onClick and scrolling is not working on touch (you can test it using chrome dev tools with the device toolbar to simulate a touch screen device): https://codesandbox.io/s/rive-react-canvas-3-0-40-ushr62?file=/src/App.js

I assume this is related to the touch and drag interactions? Is it possible to disable them for touch screens?

flogst avatar Apr 11 '23 07:04 flogst

Ahh, sorry you ran into this! I'd recommend working off 3.0.39 for now then - we'll work on a patch for you to set a flag that allows you to opt out of the behind-the-scenes event listener attachments on the canvas (disabling all Rive listeners), as well as try and be smarter about attaching any event listeners at all if there are none configured on your state machine. Would that work for you?

zplata avatar Apr 12 '23 17:04 zplata

That sounds perfect, thank you!

flogst avatar Apr 13 '23 05:04 flogst

Hi @flogst - can you try on 4.0.46? You can pass in a shouldDisableRiveListeners: true as a parameter in the useRive params.

zplata avatar May 03 '23 16:05 zplata

Hi @zplata, thanks for this. It does solve the scrolling issue, however we have one animation where we use a hover listener from Rive directly. So it's not possible to have both, the hover listener and being able to scroll if the animation is touched on a touchscreen?

flogst avatar May 11 '23 10:05 flogst

+1

RyanMerabet avatar Jun 01 '23 03:06 RyanMerabet

@flogst But this has the additional problem that there is no way to dynamically change this parameter. Very often, there is a need for interaction on the PC, but not on the phone. That means there needs to be a way to change the parameter directly, not just at initialization time.

limichange avatar Jun 07 '23 02:06 limichange

+1

edogbeatz avatar Jan 03 '24 15:01 edogbeatz

Wassup folks! are there any news on this?

edogbeatz avatar Jan 17 '24 16:01 edogbeatz