Skip to content

Commit

Permalink
fix(fisheye): reset when pointerleave (#4858)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored and hustcc committed Apr 3, 2023
1 parent 37322e7 commit 95c9e8d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions __tests__/plots/interaction/gdp2-point-chart-fisheye.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { csv } from 'd3-fetch';
import { autoType } from 'd3-dsv';
import { G2Spec, ELEMENT_CLASS_NAME } from '../../../src';
import { G2Spec, PLOT_CLASS_NAME } from '../../../src';
import { step } from './utils';

export async function gdp2PointFisheye(): Promise<G2Spec> {
Expand Down Expand Up @@ -37,12 +37,15 @@ export async function gdp2PointFisheye(): Promise<G2Spec> {

gdp2PointFisheye.steps = ({ canvas }) => {
const { document } = canvas;
const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME);
const [e] = elements;
const [plot] = document.getElementsByClassName(PLOT_CLASS_NAME);
return [
step(e, 'pointermove', {
step(plot, 'pointermove', {
offsetX: 450,
offsetY: 350,
}),
step(plot, 'pointerleave', {
offsetX: 1000,
offsetY: 1000,
}),
];
};
5 changes: 4 additions & 1 deletion src/interaction/fisheye.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export function Fisheye({
const updateFocus = throttle(
(event) => {
const focus = mousePosition(plotArea, event);
if (!focus) return;
if (!focus) {
update(options);
return;
}
const [x, y] = focus;
const fisheye = maybeCoordinate(clonedOptions);
fisheye.focusX = x;
Expand Down

0 comments on commit 95c9e8d

Please sign in to comment.