From b6ec8e217bc3ed56702c819885948839c14bf8e3 Mon Sep 17 00:00:00 2001 From: silentcloud Date: Thu, 8 Jun 2017 10:45:33 +0800 Subject: [PATCH] add delayPressIn/Out for button --- components/button/PropsType.tsx | 2 ++ components/button/index.tsx | 3 +-- components/button/index.web.tsx | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/components/button/PropsType.tsx b/components/button/PropsType.tsx index f071d9df4c..c7d6bf093f 100644 --- a/components/button/PropsType.tsx +++ b/components/button/PropsType.tsx @@ -7,6 +7,8 @@ export interface ButtonProps { disabled?: boolean; onClick?: (x?: any) => void; loading?: boolean; + delayPressIn?: number; + delayPressOut?: number; } export interface ButtonWebProps extends WebProps, ButtonProps { diff --git a/components/button/index.tsx b/components/button/index.tsx index 4caa8ecdcc..0405165825 100644 --- a/components/button/index.tsx +++ b/components/button/index.tsx @@ -65,7 +65,7 @@ export default class Button extends React.Component { } = this.props; const buttonStyles = styles!; - ['activeOpacity', 'delayPressOut', 'underlayColor', 'onPress', 'onPressIn', + ['activeOpacity', 'underlayColor', 'onPress', 'onPressIn', 'onPressOut', 'onShowUnderlay', 'onHideUnderlay'].forEach((prop) => { if (restProps.hasOwnProperty(prop)) { delete restProps[prop]; @@ -100,7 +100,6 @@ export default class Button extends React.Component { return ( onClick && onClick(e)} diff --git a/components/button/index.web.tsx b/components/button/index.web.tsx index efa433648f..a28b3a3ab1 100644 --- a/components/button/index.web.tsx +++ b/components/button/index.web.tsx @@ -37,8 +37,11 @@ class Button extends React.Component { }; render() { - const { children, className, prefixCls, type, size, inline, across, - disabled, icon, loading, activeStyle, onClick, ...restProps } = this.props; + const { + children, className, prefixCls, type, size, inline, across, + disabled, icon, loading, activeStyle, onClick, delayPressIn, + delayPressOut, ...restProps, + } = this.props; const wrapCls = { [className as string]: className, @@ -60,12 +63,20 @@ class Button extends React.Component { wrapCls[`${prefixCls}-icon`] = true; } + const delayProps: any = {}; + if (delayPressIn) { + delayProps.delayPressIn = delayPressIn; + } + if (delayPressOut) { + delayProps.delayPressOut = delayPressOut; + } // use div, button native is buggy @yiminghe return (