Incubator-echarts: 同时监听单击和双击事件的时候触发双击事件前会触发两次单击事件

Created on 28 Apr 2016  ·  5Comments  ·  Source: apache/incubator-echarts

问题简述 (One-line summary)

同时监听单击和双击事件的时候触发双击事件前会触发两次单击事件

版本及环境 (Version & Environment)

https://ecomfe.github.io/echarts/doc/example/event.html

重现步骤 (Steps to reproduce)

https://ecomfe.github.io/echarts/doc/example/event.html

示例上双击某一数据,控制台输出两个单击事件和一个双击事件

期望结果 (Expected behaviour)

同时监听单击事件和双击事件时,双击不触发单击事件

image

Most helpful comment

@shikelong 尝试下以下代码

var intervalTimer = null;

    function do_click(event) {
        clearTimeout(intervalTimer); //取消上次延时未执行的方法

        intervalTimer = setTimeout(function() {
            // click 事件的处理
        }, 500);
    }

    function do_dblclick(event) {
        clearTimeout(intervalTimer);
        // dblclick 事件的处理
    }

All 5 comments

请问你的问题怎么解决的?

@shikelong 尝试下以下代码

var intervalTimer = null;

    function do_click(event) {
        clearTimeout(intervalTimer); //取消上次延时未执行的方法

        intervalTimer = setTimeout(function() {
            // click 事件的处理
        }, 500);
    }

    function do_dblclick(event) {
        clearTimeout(intervalTimer);
        // dblclick 事件的处理
    }

谢谢。

get

请问如果是图表本身就绑定了单击事件要怎么办呢?@manmamen

Was this page helpful?
0 / 5 - 0 ratings