How to handle “single click” and “double click” on the same html DOM element using typescript:Angular 2 or 4?

前端 未结 7 1221
说谎
说谎 2020-12-08 14:43

My issue is, the methods used for both the events is getting triggered when I perform \"double click\"

For example, I need to perform specific functionality when spe

7条回答
  •  星月不相逢
    2020-12-08 15:10

    clickCount = 0;
    click() {
        this.clickCount++;
        setTimeout(() => {
            if (this.clickCount === 1) {
                 // single
            } else if (this.clickCount === 2) {
                // double
            }
            this.clickCount = 0;
        }, 250)
    }
    

提交回复
热议问题