react-konva Text - onClick does not work on mobile
Asked Answered
F

1

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?

Fotinas answered 28/4, 2017 at 13:58 Comment(1)
RTFM Konva mobile eventsHesperides
W
8

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}
/>
Wilhelminawilhelmine answered 28/4, 2017 at 16:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.