Skip to content

mobile tooltip on tap #1526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pointermove on pointerenter
  • Loading branch information
mbostock committed May 6, 2023
commit 12a52b4be0225568bb930fd2f7ba67c0d2a35a89
14 changes: 3 additions & 11 deletions src/marks/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,7 @@ export class Tooltip extends Mark {
let sticky = false;

function pointermove(event) {
if (
event.pointerType === "mouse" &&
(sticky || // clicked
event.buttons === 1) // dragging
)
return;
if (sticky || (event.pointerType === "mouse" && event.buttons === 1)) return; // dragging
const rect = svg.getBoundingClientRect();
let ii, fxi, fyi;
if (
Expand Down Expand Up @@ -211,11 +206,7 @@ export class Tooltip extends Mark {
}

function pointerdown(event) {
// fake pointermove event for touch
if (event.pointerType !== "mouse") {
sticky = false;
pointermove(event);
}
if (event.pointerType !== "mouse") return;
if (sticky) {
sticky = false;
dot.attr("display", "none");
Expand Down Expand Up @@ -255,6 +246,7 @@ export class Tooltip extends Mark {
// us receive pointer events from farther away, but would also make it hard
// to know when to remove the listeners. (Using a mutation observer to watch
// the entire document is likely too expensive.)
svg.addEventListener("pointerenter", pointermove);
svg.addEventListener("pointermove", pointermove);
svg.addEventListener("pointerdown", pointerdown);
svg.addEventListener("pointerleave", pointerleave);
Expand Down