0

I have the following series of events:

The user presses an element on his touch screen. This causes a new page to load. The user does not lift his finger from the screen.

Now, I would like to register where his finger is on the new page (or where it is if he moves it). However, ontouchmove and ontouchstart only seem to fire if he lifts his finger and then touches the screen again.

Is there an event that fires?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user984003
  • 28,050
  • 64
  • 189
  • 285

2 Answers2

1

As far as I could find, there isn't an event that fires, and it seems that there isn't a great way of detecting the position of the touch (or mouse) on load.

One option would be to keep track of the current position and state, and pass that to the new page. See Eugene's answer on JavaScript: Check if mouse button down? for an example of tracking mouse clicks, adding in position is similar.

The final piece is then following movements once the page has loaded. For a mouse, you could use the mouseMove event, but for touches, if the touchMove event is not firing, you might be out of luck. You could try firing the touchStart event manually.

Community
  • 1
  • 1
Carson Darling
  • 310
  • 1
  • 9
0

I think the key is to use Ajax. That way new stuff can be loaded, but the touchmove event will continue to fire.

I did not try this because I ended up, instead, loading everything to begin with and then handling everything in javascript. This way I never needed to reload the page. Of course, this only works with a basic page, but I'm guessing that ajax would work for pages that need server action.

user984003
  • 28,050
  • 64
  • 189
  • 285