Skip to content

Commit

Permalink
fix(zoom): Remove unused wheel listener
Browse files Browse the repository at this point in the history
- Remove unused mouse wheel event bind, where added as part of workaound for chrome
- Apply code format

Ref #3791
  • Loading branch information
netil committed Jun 7, 2024
1 parent f6201ad commit 9be3921
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/ChartInternal/interactions/zoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,6 @@ export default {
const {config, $el: {eventRect}} = $$;
const behaviour = config.zoom_type === "drag" ? $$.zoomBehaviour : $$.zoom;

// Since Chrome 89, wheel zoom not works properly
// Applying the workaround: https://github.com/d3/d3-zoom/issues/231#issuecomment-802305692
$$.$el.svg.on("wheel", () => {});

eventRect?.call(behaviour)
.on("dblclick.zoom", null);
},
Expand Down
3 changes: 2 additions & 1 deletion src/module/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,8 @@ function convertInputType(mouse: boolean, touch: boolean): "mouse" | "touch" | n
// Check if agent has mouse using any-hover, touch devices (e.g iPad) with external mouse will return true as long as mouse is connected
// https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/#aa-testing-the-capabilities-of-all-inputs
// Demo: https://patrickhlauke.github.io/touch/pointer-hover-any-pointer-any-hover/
const hasMouse = mouse && (matchMedia?.("any-hover:hover").matches || matchMedia?.("any-pointer:fine").matches);
const hasMouse = mouse &&
(matchMedia?.("any-hover:hover").matches || matchMedia?.("any-pointer:fine").matches);

// fallback to 'mouse' if no input type is detected.
return (hasMouse && "mouse") || (hasTouch && "touch") || "mouse";
Expand Down

0 comments on commit 9be3921

Please sign in to comment.