Skip to content

Commit

Permalink
refactor: do not support triggerOn callback usage for tooltip and leg…
Browse files Browse the repository at this point in the history
…end.
  • Loading branch information
simaQ committed Jul 30, 2018
1 parent d507b92 commit 33624cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
12 changes: 2 additions & 10 deletions src/plugin/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,22 +359,14 @@ class LegendController {
const legendCfg = this.legendCfg;
const triggerOn = legendCfg.triggerOn || 'touchstart';
const method = Util.wrapBehavior(this, 'handleEvent');
if (Util.isFunction(triggerOn)) {
triggerOn(method, 'bind');
} else {
Util.addEventListener(this.canvasDom, triggerOn, method);
}
Util.addEventListener(this.canvasDom, triggerOn, method);
}

unBindEvents() {
const legendCfg = this.legendCfg;
const triggerOn = legendCfg.triggerOn || 'touchstart';
const method = Util.getWrapBehavior(this, 'handleEvent');
if (Util.isFunction(triggerOn)) {
triggerOn(method, 'unBind');
} else {
Util.removeEventListener(this.canvasDom, triggerOn, method);
}
Util.removeEventListener(this.canvasDom, triggerOn, method);
}
}
module.exports = {
Expand Down
4 changes: 1 addition & 3 deletions src/plugin/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,7 @@ class TooltipController {
_handleEvent(methodName, method, action) {
const canvasDom = this.canvasDom;
Util.each([].concat(methodName), aMethod => {
if (Util.isFunction(aMethod)) {
aMethod(method, action); // TODO: 测试,供用户自己绑定事件
} else if (action === 'bind') {
if (action === 'bind') {
Util.addEventListener(canvasDom, aMethod, method);
} else {
Util.removeEventListener(canvasDom, aMethod, method);
Expand Down

0 comments on commit 33624cb

Please sign in to comment.