5

I'm using react-konva in my webapp and on the desktop browser it works perfectly, but on the mobile browser the onClick does not work.

<Text
    key={index}
    index={index}
    x={position[0]}
    y={position[1]}
    fontSize={unit}
    width={unit}
    text={mark}
    fill={fill}
    fontFamily={'Helvetica'}
    align={'center'}
    onClick={ (event) => {
      alert("Some text...")
    }}
/>

Is there a way to get this to work on mobile or do I need to find a replacement for react-konva text?

Alon
  • 883
  • 1
  • 6
  • 18

1 Answers1

7

You have to use a special mobile event: onTap.

https://konvajs.github.io/docs/events/Mobile_Events.html

So in your case just use onClick and onTap together.

<Text
   {...attrs}
   onClick={this.handleClick}
   onTap={this.handleClick}
/>
lavrton
  • 18,973
  • 4
  • 30
  • 63