I want to move the touch event that took place on the JavaScript element to another element.

Asked 1 years ago, Updated 1 years ago, 27 views

Creating web applications for smartphones.
The screen is divided into a content area, a middle area, and a touch area.
capture image

I want to touch the touch area below to scroll and tap the top content area.

For touchstart, touchmove, touchend,

function dispatch(e){
    varevt= document.createEvent('Event')
    evt.initEvent(e.type, true, true)
    contentArea.dispatchEvent(evt)
}

I'm trying to create a new event and send a touch event as shown in , but it doesn't work. Specifically, touchstart, touchmove, touchmove that occurred in the touch area seem to be sent to an element in the content area.

I would appreciate it if you could let me know if anyone could tell me.

javascript

2022-09-30 19:40

1 Answers

Browsers are specifically designed not to react to events artificially created from the program.

Therefore, you need to give up creating events and dispatching them, and write your own scrolling code.


2022-09-30 19:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.