Skip to content

Commit

Permalink
Merge pull request #97 from heart2friend/touch-during-scroll-issue
Browse files Browse the repository at this point in the history
Exposed delayPressIn and delayPressOut properties. Used delayPressIn …
  • Loading branch information
marcocesarato authored Apr 20, 2023
2 parents 1abbdc7 + bf868ee commit 0bbf32c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export default class App extends Component {
<Text style={Styles.title}>
Example{"\n"}react-native-input-spinner
</Text>
<View style={Styles.col}>
<Text style={Styles.text}>Prevent auto increment on scroll</Text>
<InputSpinner value={this.state.value} style={Styles.spinner} delayPressIn={100}/>
</View>
<View style={Styles.col}>
<Text style={Styles.text}>Standard</Text>
<InputSpinner value={this.state.value} style={Styles.spinner} />
Expand Down
8 changes: 8 additions & 0 deletions src/InputSpinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
*/
export const defaultSpeed = 7;
export const defaultAccelerationDelay = 1000;
export const defaultDelayPressIn = 0;
export const defaultDelayPressOut = 0;
export const defaultTypingTime = 500;

/**
Expand Down Expand Up @@ -1260,7 +1262,9 @@ class InputSpinner extends Component {
disabled={this._isDisabledButtonLeft()}
style={buttonStyle}
onPressIn={this.decrease.bind(this)}
delayPressIn={this.props.delayPressIn}
onPressOut={this.onPressOut.bind(this)}
delayPressOut={this.props.delayPressOut}
onLongPress={this.decreaseHold.bind(this)}
delayLongPress={this.props.accelerationDelay}
{...this.props.leftButtonProps}>
Expand Down Expand Up @@ -1300,7 +1304,9 @@ class InputSpinner extends Component {
disabled={this._isDisabledButtonRight()}
style={buttonStyle}
onPressIn={this.increase.bind(this)}
delayPressIn={this.props.delayPressIn}
onPressOut={this.onPressOut.bind(this)}
delayPressOut={this.props.delayPressOut}
onLongPress={this.increaseHold.bind(this)}
delayLongPress={this.props.accelerationDelay}
{...this.props.rightButtonProps}>
Expand Down Expand Up @@ -1502,6 +1508,8 @@ InputSpinner.defaultProps = {
width: "auto",
height: 50,
accelerationDelay: defaultAccelerationDelay,
delayPressIn: defaultDelayPressIn,
delayPressOut: defaultDelayPressOut,
speed: defaultSpeed,
emptied: false,
continuity: false,
Expand Down
2 changes: 2 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export interface ReactNativeInputSpinnerProps {
onSubmit?(...args: unknown[]): unknown;
onLongPress?(...args: unknown[]): unknown;
accelerationDelay?: number;
delayPressIn?: number,
delayPressOut?: number,
speed?: number;
emptied?: boolean;
continuity?: boolean;
Expand Down

0 comments on commit 0bbf32c

Please sign in to comment.