From d11bbbd4207021c67e6b692d8ad0b3d5a1a3f169 Mon Sep 17 00:00:00 2001 From: jonyshi Date: Wed, 2 May 2018 15:35:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E7=9A=84onclick=E5=92=8ConDoubleclick?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/TableRow.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/TableRow.js b/src/TableRow.js index 3e9c8c1..8ffe90a 100644 --- a/src/TableRow.js +++ b/src/TableRow.js @@ -43,6 +43,7 @@ const defaultProps = { class TableRow extends Component{ constructor(props){ super(props); + this._timeout = null; this.state = { hovered: false, }; @@ -86,11 +87,14 @@ class TableRow extends Component{ if (expandable && expandRowByClick) { onExpand(!expanded, record, index,event); } - onRowClick(record, index, event); + this.set((e)=> { + onRowClick(record, index, event); + }); } onRowDoubleClick(event) { const { record, index, onRowDoubleClick } = this.props; + this.clear(); onRowDoubleClick(record, index, event); } @@ -104,6 +108,17 @@ class TableRow extends Component{ onHover(false, hoverKey); } + set =(fn)=> { + this.clear(); + this._timeout = window.setTimeout(fn, 300); + } + + clear =(event)=> { + if (this._timeout) { + window.clearTimeout(this._timeout); + } + } + render() { const { clsPrefix, columns, record, height, visible, index,