wf123537200 commented on issue #12864:
URL: 
https://github.com/apache/incubator-echarts/issues/12864#issuecomment-650939842


   I think use ua is a better way?
    /(Mobile|Android|Windows Phone)/.test(navigator.userAgent) to judge 
isTouchDevice and use window.TouchEvent to judge hasTouch.
   
   2020年6月29日 下午1:29,Zhongxiang.Wang 
<[email protected]<mailto:[email protected]>> 写道:
   
   
   Brief
   
   There are some issues reporting echarts can't detect properly whether 
touch-screen device supports touch events or not.
   
     *   #7406<https://github.com/apache/incubator-echarts/issues/7406>
     *   #9301<https://github.com/apache/incubator-echarts/issues/9301>
     *   #12166<https://github.com/apache/incubator-echarts/issues/12166>
     *   #12823<https://github.com/apache/incubator-echarts/issues/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
   
   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
   
   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.
   
   —
   You are receiving this because you are subscribed to this thread.
   Reply to this email directly, view it on 
GitHub<https://github.com/apache/incubator-echarts/issues/12864>, or 
unsubscribe<https://github.com/notifications/unsubscribe-auth/ABHESIDBPLNLA46M4A4WHN3RZARDLANCNFSM4OK5HN7Q>.
   
   


----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to