react fake double , bind click and dblclick on the same element

Posted zyip

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了react fake double , bind click and dblclick on the same element相关的知识,希望对你有一定的参考价值。

 

 

smartClick:function(id,name,waiter,e){
                var desk = $$(e.currentTarget).data(‘raw‘);
                if(this.lastClickTime[id] && ((new Date())-this.lastClickTime[id])>70)
                {//quick click twice , it seems a dblclick
                    console.log(‘dblclick‘);
                    this.lastClickTime[id]=undefined;
                    this.clickHandler && clearTimeout(this.clickHandler);
                    this.clickHandler = 0;
                    return;
                }

                if(!this.clickHandler)
                {
                    this.clickHandler=setTimeout(function(){
                        console.log(‘click‘);
                        this.lastClickTime[id]=undefined;
                        clearTimeout(this.clickHandler);
                        this.clickHandler = 0;
                    }.bind(this),300);
                    this.lastClickTime[id]=new Date();    
                }                
                return;
                
            },

 

以上是关于react fake double , bind click and dblclick on the same element的主要内容,如果未能解决你的问题,请参考以下文章

(翻译)测试替身— Fakes, Mocks 和 Stubs

想在方程式中使用@Binding 变量

react中为啥不window.location.href来跳转,还要用react-router来跳转

在 React 事件处理程序中使用 .bind() 时出错

React onClick/onChange 传参 (bind绑定)

javascript React,removeEventListener和bind(this)gotcha