Skip to content

Commit

Permalink
Add new Callback to Swiper
Browse files Browse the repository at this point in the history
Add new Callback to Swiper:
onSwipeStart : function  
onSwipeEnd : funciton

onSwipeStart is called when a gesture has started. Usefull when you want to do something when swipe begin no mater the direction of the swipe.
onSwipeEnd is called at the end of swipping when user has released all touches. Usefull when you want to do something when swipe end no mater the direction of the swipe.
  • Loading branch information
dopey2 authored Nov 2, 2018
1 parent 4bf9717 commit 6b0c3e4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Swiper.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class Swiper extends Component {
}

onPanResponderGrant = (event, gestureState) => {
this.props.onSwipeStart()
if (!this.state.panResponderLocked) {
this.state.pan.setOffset({
x: this._animatedValueX,
Expand Down Expand Up @@ -249,6 +250,7 @@ class Swiper extends Component {
}

onPanResponderRelease = (e, gestureState) => {
this.props.onSwipeEnd()
if (this.state.panResponderLocked) {
this.state.pan.setValue({
x: 0,
Expand Down Expand Up @@ -828,6 +830,8 @@ Swiper.propTypes = {
onSwipedRight: PropTypes.func,
onSwipedTop: PropTypes.func,
onSwiping: PropTypes.func,
onSwipeStart: PropTypes.func,
onSwipeEnd: PropTypes.func,
onTapCard: PropTypes.func,
onTapCardDeadZone: PropTypes.number,
outputCardOpacityRangeX: PropTypes.array,
Expand Down Expand Up @@ -910,6 +914,8 @@ Swiper.defaultProps = {
onSwipedTop: cardIndex => { },
onSwipedBottom: cardIndex => { },
onSwipedAll: () => { },
onSwipeStart: () => { },
onSwipeEnd: () => { },
onTapCard: (cardIndex) => { },
onTapCardDeadZone: 5,
outputCardOpacityRangeX: [0.8, 1, 1, 1, 0.8],
Expand Down

0 comments on commit 6b0c3e4

Please sign in to comment.