From 472dd2c3d218c368fb04208ec76247fe6bd50a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E4=BB=AA?= Date: Thu, 21 Jul 2016 18:05:49 +0800 Subject: [PATCH] =?UTF-8?q?onPopupVisibleChange=20=E5=A2=9E=E5=8A=A0event?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Trigger.jsx | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Trigger.jsx b/src/Trigger.jsx index 304ab540..1f29eb37 100644 --- a/src/Trigger.jsx +++ b/src/Trigger.jsx @@ -188,26 +188,26 @@ const Trigger = React.createClass({ } }, - onMouseEnter() { - this.delaySetPopupVisible(true, this.props.mouseEnterDelay); + onMouseEnter(event) { + this.delaySetPopupVisible(true, this.props.mouseEnterDelay, event); }, - onMouseLeave(e) { + onMouseLeave(event) { // https://github.com/react-component/trigger/pull/13 // react bug? - if (e.relatedTarget && !e.relatedTarget.setTimeout && - contains(this.popupContainer, e.relatedTarget)) { + if (event.relatedTarget && !event.relatedTarget.setTimeout && + contains(this.popupContainer, event.relatedTarget)) { return; } - this.delaySetPopupVisible(false, this.props.mouseLeaveDelay); + this.delaySetPopupVisible(false, this.props.mouseLeaveDelay, event); }, - onFocus() { + onFocus(event) { // incase focusin and focusout this.clearDelayTimer(); if (this.isFocusToShow()) { this.focusTime = Date.now(); - this.delaySetPopupVisible(true, this.props.focusDelay); + this.delaySetPopupVisible(true, this.props.focusDelay, event); } }, @@ -219,10 +219,10 @@ const Trigger = React.createClass({ this.preTouchTime = Date.now(); }, - onBlur() { + onBlur(event) { this.clearDelayTimer(); if (this.isBlurToHide()) { - this.delaySetPopupVisible(false, this.props.blurDelay); + this.delaySetPopupVisible(false, this.props.blurDelay, event); } }, @@ -247,7 +247,7 @@ const Trigger = React.createClass({ event.preventDefault(); const nextVisible = !this.state.popupVisible; if (this.isClickToHide() && !nextVisible || nextVisible && this.isClickToShow()) { - this.setPopupVisible(!this.state.popupVisible); + this.setPopupVisible(!this.state.popupVisible, event); } }, @@ -256,7 +256,7 @@ const Trigger = React.createClass({ const root = findDOMNode(this); const popupNode = this.getPopupDomNode(); if (!contains(root, target) && !contains(popupNode, target)) { - this.setPopupVisible(false); + this.setPopupVisible(false, event); } }, @@ -294,7 +294,7 @@ const Trigger = React.createClass({ return popupAlign; }, - setPopupVisible(popupVisible) { + setPopupVisible(popupVisible, event) { this.clearDelayTimer(); if (this.state.popupVisible !== popupVisible) { if (!('popupVisible' in this.props)) { @@ -302,20 +302,20 @@ const Trigger = React.createClass({ popupVisible, }); } - this.props.onPopupVisibleChange(popupVisible); + this.props.onPopupVisibleChange(popupVisible, event); } }, - delaySetPopupVisible(visible, delayS) { + delaySetPopupVisible(visible, delayS, event) { const delay = delayS * 1000; this.clearDelayTimer(); if (delay) { this.delayTimer = setTimeout(() => { - this.setPopupVisible(visible); + this.setPopupVisible(visible, event); this.clearDelayTimer(); }, delay); } else { - this.setPopupVisible(visible); + this.setPopupVisible(visible, event); } },