fgfrutos / Etch_a_sketch

A simple Etch a sketch implementation.
0 stars 0 forks source link

Add the hovering effect to mobile devices #1

Open fgfrutos opened 2 years ago

fgfrutos commented 2 years ago

For personal reasons, I'm very interested in make this project responsive to mobile devices. I have though about use touchstart and touchmove to emulate the hovering effect with fingers. The problem is that it seems that touchmove only modify the element that was touched in the first place (if you try to get the element touched using e.target the element that you get is the first element touched).

To overcome that problem it seems to be possible to select the element currently touched using document.elementFromPoint(x, y), where x and y are the coordinates from the client's point of view. I have found this possible implementation here.

fgfrutos commented 2 years ago

I have been making some trials in devtools and it seems to work. But it may be necessary to disable scrolling when the touch is started in the sketch container to make possible to draw without the problem of scrolling the entire page.