Home > Blockchain >  Dispatching a touch event with two touch points to use chrome dev tools debugging
Dispatching a touch event with two touch points to use chrome dev tools debugging

Time:01-18

First off, I know there's been a question about this and all the information I've found is old. Everyone says to toggle device in chrome dev tools and hold shift while clicking and dragging. This does NOT work anymore.

Now I know that we can use android studio, but honestly it's clunky and slow. My question is, is there a way to create some function that dispatches a synthetic touch event so that chrome devtools can break with a debugger statement in a touch event listener that handles pinching, or two touch points that is?

I know about browser stack, or using an emulator with android studio. Since I use iOS, I've been using safari dev tools with remote debugging which I don't really like. It would be nice to be able to use debugging directly in chrome dev tools to test multiple touch points rather than having to do remote debugging.

Is there a way to somehow make chrome think a pinch happened, because debugging with chrome with mobile device on, always shows one touchpoint.

CodePudding user response:

Currently, there is no built-in way to simulate multiple touch points in Chrome DevTools. However, there are a few third-party tools and libraries that can help you simulate touch events in Chrome DevTools.

One option is to use the Chrome DevTools Protocol, which allows you to programmatically interact with Chrome DevTools. This can be done using a library like puppeteer, which provides a high-level API for controlling headless Chrome or Chromium. Puppeteer can simulate touch events by using the touchscreen emulation feature.

Another option is to use a tool like Hammer.js, which is a JavaScript library that makes it easy to add touch gestures to web pages. Hammer.js can simulate touch events in Chrome DevTools by using the browser's built-in touch event support.

Keep in mind that simulating touch events in Chrome DevTools may not give you the same level of accuracy and reliability as testing on a real device. It's always best to test on real devices as much as possible.

In addition, some browsers like Firefox, Safari, and Edge have developer tools that allow you to use touch events and simulate touch interactions, you could also try using one of those.

  • Related