plainheart opened a new issue #12864:
URL: https://github.com/apache/incubator-echarts/issues/12864


   ### Brief
   There are some issues reporting echarts can't detect properly whether 
touch-screen device supports touch events or not.
   - #7406
   - #9301
   - #12166
   - #12823
   
   Current detection way in 
[`zrender/src/core/env.js`](https://github.com/ecomfe/zrender/blob/master/src/core/env.js#L149)
 is not enough to be compatible with all kinds of devices.
   
   And I searched on 
[StackOverflow](https://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript),
 but it seems there is no the best way.
   
   Therefore, for more compatibilities, should we allow the developer to config 
it manually according to what themselves know about their devices?
   For example, we may add a new option into zrender and echarts to specify 
whether touch event is supported.
   I have no such touchable device to test these, though.
   
   ECharts
   ```js
   var zr = this._zr = zrender.init(dom, {
       renderer: opts.renderer || defaultRenderer,
       devicePixelRatio: opts.devicePixelRatio,
       width: opts.width,
       height: opts.height,
       touchEventsSupported: opts.touchEventsSupported
   });
   ```
   ZRender
   overrides `env.touchEventsSupported` if developer has specified manually
   ```js
   if (opts.touchEventsSupported != null) {
       env.touchEventsSupported = !!opts.touchEventsSupported;
   }
   ```
   
   Maybe this looks a blit weird.
   Of course, it would be better if there could be a good way to detect 
touchable device.
   
   ### Others
   In `highcharts`, it use `/(Mobile|Android|Windows 
Phone)/.test(navigator.userAgent)` to judge `isTouchDevice` and use 
`window.TouchEvent`  to judge `hasTouch`.
   
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   <!-- This issue is in English. DO NOT REMOVE -->


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org
For additional commands, e-mail: commits-h...@echarts.apache.org

Reply via email to