Tooltip window positioned incorrectly when zoomed
Opened this issue · 10 comments
Can you check where the positions are coming from? This may be a Vega issue.
I don't see this issue in Chrome.
I don't see it on Chrome either, nor on Firefox (although FF doesn't have pinch-zoom anyway).
The problem isn't due to zooming, it is due to scrolling: tooltip positions are correct when zoomed if the scroll position at the upper-leftmost corner. As the document is scrolled, the tooltips start to drift off from the correct location.
It looks like the position is being calculated by https://github.com/vega/vega-tooltip/blob/master/src/position.ts Apparently, event.clientX
property in Safari is in page coordinates but in other browsers it is in window coordinates. If I change position.ts
to use pageX
/pageY
instead of clientX
/clientY
, then it works for me in Safari when zooming, and it continues to work correctly in Chrome and Firefox on macOS (I don't have IE, so I can't test there).
Hmm, that seems to be incorrect when I scroll. See http://localhost:3000/vega-examples.html for example.
Is that in Chrome or Safari? It would be a shame if we had to check the user-agent and use different logic for the different browsers.
This is in chrome.
I had a similar problem with a vega inside a container with transform: scale(xxx)
style. Exploring the call stack, I may have identified a lag between the "inner" coordinates (the one of the scenes, affected by the transform) and the "outer" coordinates (the ones of the canvas mouseover event, related to the client) here.
Switching to the svg render resolved the issue, since the event targets are directly computed by the browser.