Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-konva Text - onClick does not work on mobile

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?

like image 529
Alon Avatar asked Apr 28 '17 13:04

Alon


1 Answers

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}
/>
like image 62
lavrton Avatar answered Oct 15 '22 19:10

lavrton