1

I'm newbie using react and I'm trying now to get when a phone user touch screen, my web app interpretes that like the user has touched in another screen point. For example, a bit above.

I'm trying this:

 onTouchStart = {(event) => {
     event.touches [0] .pageY = event.touches [0] .pageY + 250;
   }
 });

But I'm getting this: ** Uncaught TypeError: Can not assign to read only property 'pageY' of object '# ' **

How can I fix it? Can I get same results with another way? If you can give me a hand I really will to thank you. Thank you in advance.

Andrew Miroshnichenko
  • 2,015
  • 15
  • 21

1 Answers1

0

Are you talking about browser and ReactJS(not React Native)? If yes, interception of user actions are prohibited inheretely by browsers, to prevent security breaches and user abuse. You can only read properties of user-originated events(and use them further in your app), but not alter them.

Andrew Miroshnichenko
  • 2,015
  • 15
  • 21
  • Yeah, is about browser and ReactJS. So, can I do this using another way? Do you know how do it? – Eugenio Salgado Mar 20 '18 at 08:55
  • 1
    Well, i guess i depends on what you want to achieve with this. If you just want to manipulate the value of pageY for further use, you could just create a variable for it and use it later on or call some function that does something with this value. Like @andrew-miroshnichenko said, there shouldn't be a reason to manipulate the event itself, rather then it's consequences. – NickG Mar 20 '18 at 09:18
  • Thanks for your reply. Excuse me if this sounds silly but, I can use this value in another variable, but how can I get web app use this variable when I touch the screen? I want to modify the place where the user touchs. Is it possible? – Eugenio Salgado Mar 20 '18 at 09:53
  • No, it isn't due to security concerns, as I say earlier. – Andrew Miroshnichenko Mar 20 '18 at 10:50