[v11.2.x] VizTooltip: Fix positioning at bottom and right edges on mobile (#92138)
VizTooltip: Fix positioning at bottom and right edges on mobile (#92042)
(cherry picked from commit 74ebc66520)
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
co-authored by
Leon Sorokin
parent
41b48033e7
commit
37ee9e22b5
@@ -313,8 +313,10 @@ export const TooltipPlugin2 = ({
|
|||||||
}
|
}
|
||||||
// only pinnable tooltip is visible *and* is within proximity to series/point
|
// only pinnable tooltip is visible *and* is within proximity to series/point
|
||||||
else if (_isHovering && closestSeriesIdx != null && !_isPinned) {
|
else if (_isHovering && closestSeriesIdx != null && !_isPinned) {
|
||||||
_isPinned = true;
|
setTimeout(() => {
|
||||||
scheduleRender(true);
|
_isPinned = true;
|
||||||
|
scheduleRender(true);
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -608,14 +610,29 @@ export const TooltipPlugin2 = ({
|
|||||||
size.width = width;
|
size.width = width;
|
||||||
size.height = height;
|
size.height = height;
|
||||||
|
|
||||||
const event = plot!.cursor.event;
|
let event = plot!.cursor.event;
|
||||||
|
|
||||||
// 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
|
||||||
|
const isMobile = event.type !== 'mousemove';
|
||||||
|
|
||||||
|
if (isMobile) {
|
||||||
|
event = new MouseEvent('mousemove', {
|
||||||
|
view: window,
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
clientX: event.clientX,
|
||||||
|
clientY: event.clientY,
|
||||||
|
screenX: event.screenX,
|
||||||
|
screenY: event.screenY,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// this works around the fact that uPlot does not unset cursor.event (for perf reasons)
|
// this works around the fact that uPlot does not unset cursor.event (for perf reasons)
|
||||||
// so if the last real mouse event was mouseleave and you manually trigger u.setCursor()
|
// so if the last real mouse event was mouseleave and you manually trigger u.setCursor()
|
||||||
// it would end up re-dispatching mouseleave
|
// it would end up re-dispatching mouseleave
|
||||||
const isStaleEvent = performance.now() - event.timeStamp > 16;
|
const isStaleEvent = isMobile ? false : performance.now() - event.timeStamp > 16;
|
||||||
|
|
||||||
!isStaleEvent && plot!.over.dispatchEvent(event);
|
!isStaleEvent && plot!.over.dispatchEvent(event);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user