VizTooltip: Check useragent to perform consistently on all mobile devices (#99655)
* Add useragent check to be comprehensive * move check outside function and add hopefully clarifying comment
This commit is contained in:
@@ -108,6 +108,8 @@ const maybeZoomAction = (e?: MouseEvent | null) => e != null && !e.ctrlKey && !e
|
|||||||
|
|
||||||
const getDataLinksFallback: GetDataLinksCallback = () => [];
|
const getDataLinksFallback: GetDataLinksCallback = () => [];
|
||||||
|
|
||||||
|
const userAgentIsMobile = /Android|iPhone|iPad/i.test(navigator.userAgent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @alpha
|
* @alpha
|
||||||
*/
|
*/
|
||||||
@@ -666,8 +668,9 @@ export const TooltipPlugin2 = ({
|
|||||||
|
|
||||||
// if not viaSync, re-dispatch real event
|
// if not viaSync, re-dispatch real event
|
||||||
if (event != null) {
|
if (event != null) {
|
||||||
// we expect to re-dispatch mousemove, but on mobile we'll get mouseup or click
|
// we expect to re-dispatch mousemove, but may have a different event type, so create a mousemove event and fire that instead
|
||||||
const isMobile = event.type !== 'mousemove';
|
// this doesn't work for every mobile device, so fall back to checking the useragent as well
|
||||||
|
const isMobile = event.type !== 'mousemove' || userAgentIsMobile;
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
event = new MouseEvent('mousemove', {
|
event = new MouseEvent('mousemove', {
|
||||||
|
|||||||
Reference in New Issue
Block a user