Search code examples
javascripttouch-event

Is it possible to trigger programmatically on website opened via phone?


I need to trigger swipe programmatically like on below gif example

Desired behaviour

I looked in chrome devtools and this swipe calls 3 events: touchstart, touchmove, touchend so probably I need somehow trigger these 3 events to reach such result. Any ideas?


Solution

  • If you are looking to smoothly scroll the page, you can use element.scroll() and set top to how many pixels from the top you want it to scroll by.

    element.scroll({ top: 100, behavior: "smooth" });