小编jos*_*arr的帖子

在debounced函数中d3.event为null

尝试使用去抖动版本的mousemove事件处理程序时,d3.eventnull.我想d3.mouse在这个debounced处理程序中使用该对象,但d3.event返回null并抛出错误.我如何能够访问d3.event以下代码:

// a simple debounce function
function debounce(func, wait, immediate) {
  var timeout;
  return function() {
    var context = this, args = arguments;
    var later = function() {
      timeout = null;
      if (!immediate) {
        func.apply(context, args);
      }
    };
    var callNow = immediate && !timeout;
    clearTimeout(timeout);
    timeout = setTimeout(later, wait);
    if (callNow) {
      func.apply(context, args);
    }
  };
}

// the function to handle the mouse move
function handleMousemove ( context ) …
Run Code Online (Sandbox Code Playgroud)

javascript svg dom-events d3.js

6
推荐指数
1
解决办法
2839
查看次数

标签 统计

d3.js ×1

dom-events ×1

javascript ×1

svg ×1