Skip to content

Commit

Permalink
fix(visualMap): fix continuous visualMap mouseover event not register…
Browse files Browse the repository at this point in the history
… except first countinous visualMap (#19097)

* fix(visualMap): fix continuous visualMap mouseover event not register except first countinous visualMap

* fix(visualMap): bind current instance to eventHandler to make unique function in init function

* fix(visualMap): remove unnecessary declaration and assignment

---------

Co-authored-by: plainheart <[email protected]>
  • Loading branch information
linghaoSu and plainheart authored Sep 11, 2023
1 parent 428e2ad commit a06dd62
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 15 deletions.
23 changes: 9 additions & 14 deletions src/component/visualMap/ContinuousView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,19 @@ class ContinuousView extends VisualMapView {

private _firstShowIndicator: boolean;

private _api: ExtensionAPI;
init(ecModel: GlobalModel, api: ExtensionAPI) {
super.init(ecModel, api);

this._hoverLinkFromSeriesMouseOver = zrUtil.bind(this._hoverLinkFromSeriesMouseOver, this);
this._hideIndicator = zrUtil.bind(this._hideIndicator, this);
}

doRender(
visualMapModel: ContinuousModel,
ecModel: GlobalModel,
api: ExtensionAPI,
payload: {type: string, from: string}
) {
this._api = api;

if (!payload || payload.type !== 'selectDataRange' || payload.from !== this.uid) {
this._buildView();
}
Expand Down Expand Up @@ -711,7 +713,7 @@ class ContinuousView extends VisualMapView {
for (let i = 0; i < handleLabels.length; i++) {
// Fade out handle labels.
// NOTE: Must use api enter/leave on emphasis/blur/select state. Or the global states manager will change it.
this._api.enterBlur(handleLabels[i]);
this.api.enterBlur(handleLabels[i]);
}
}
}
Expand Down Expand Up @@ -856,7 +858,7 @@ class ContinuousView extends VisualMapView {
for (let i = 0; i < handleLabels.length; i++) {
// Fade out handle labels.
// NOTE: Must use api enter/leave on emphasis/blur/select state. Or the global states manager will change it.
this._api.leaveBlur(handleLabels[i]);
this.api.leaveBlur(handleLabels[i]);
}
}
}
Expand All @@ -874,6 +876,7 @@ class ContinuousView extends VisualMapView {
this._hideIndicator();

const zr = this.api.getZr();

zr.off('mouseover', this._hoverLinkFromSeriesMouseOver);
zr.off('mouseout', this._hideIndicator);
}
Expand All @@ -892,7 +895,7 @@ class ContinuousView extends VisualMapView {
: graphic.transformDirection(vertex, transform, inverse);
}

// TODO: TYPE more specified payload types.
// TODO: TYPE more specified payload types.
private _dispatchHighDown(type: 'highlight' | 'downplay', batch: Payload['batch']) {
batch && batch.length && this.api.dispatchAction({
type: type,
Expand All @@ -908,14 +911,6 @@ class ContinuousView extends VisualMapView {
this._clearHoverLinkToSeries();
}

/**
* @override
*/
remove() {
this._clearHoverLinkFromSeries();
this._clearHoverLinkToSeries();
}

}

function createPolygon(
Expand Down
3 changes: 2 additions & 1 deletion test/runTest/actions/__meta__.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/runTest/actions/visualMap-multi-continuous.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a06dd62

Please sign in to comment.