Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "feat: supports deleting all events of the corresponding type without passing through the handler when calling off\n\n",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "lixuef1313@163.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "feat: supports deleting all events of the corresponding type without passing through the handler when calling off\n\n",
"type": "patch",
"packageName": "@visactor/vutils-extension"
}
],
"packageName": "@visactor/vutils-extension",
"email": "lixuef1313@163.com"
}
16 changes: 12 additions & 4 deletions packages/vchart/src/core/vchart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,11 +958,19 @@ export class VChart implements IVChart {
this._event?.on(eType as any, query as any, handler as any);
}
off(eType: string, handler?: EventCallback<EventParams>): void {
const index = this._userEvents.findIndex(e => e.eType === eType && e.handler === handler);
if (index >= 0) {
this._userEvents.splice(index, 1);
if (handler) {
const index = this._userEvents.findIndex(e => e.eType === eType && e.handler === handler);
if (index >= 0) {
this._userEvents.splice(index, 1);
}
} else {
this._userEvents.forEach(e => {
if (e.eType === eType) {
this._event?.off(eType, e.handler);
}
});
this._userEvents = this._userEvents.filter(e => e.eType !== eType);
}
this._event?.off(eType, handler);
}

// 状态相关方法
Expand Down