Skip to content

Commit

Permalink
add delayPressIn/Out for button
Browse files Browse the repository at this point in the history
  • Loading branch information
silentcloud committed Jun 8, 2017
1 parent a245c9a commit b6ec8e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions components/button/PropsType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions components/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class Button extends React.Component<ButtonNativeProps, any> {
} = 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];
Expand Down Expand Up @@ -100,7 +100,6 @@ export default class Button extends React.Component<ButtonNativeProps, any> {
return (
<TouchableHighlight
activeOpacity={1}
delayPressOut={1}
underlayColor={underlayColor}
style={wrapperStyle}
onPress={(e?: any) => onClick && onClick(e)}
Expand Down
15 changes: 13 additions & 2 deletions components/button/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ class Button extends React.Component<ButtonWebProps, any> {
};

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,
Expand All @@ -60,12 +63,20 @@ class Button extends React.Component<ButtonWebProps, any> {
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 (
<Touchable
activeClassName={activeStyle ? `${prefixCls}-active` : undefined}
disabled={disabled}
activeStyle={activeStyle}
{...delayProps}
>
<a
role="button"
Expand Down

0 comments on commit b6ec8e2

Please sign in to comment.