Skip to content

Commit

Permalink
Merge pull request leecade#1 from Akarsh08/fix/onTouchHandle
Browse files Browse the repository at this point in the history
Fix/on touch handle
  • Loading branch information
Akarsh08 authored Feb 3, 2020
2 parents 9e50938 + 9ec45bd commit f6c6a3c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 10 deletions.
48 changes: 48 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"updtr": "^2.0.0"
},
"dependencies": {
"@react-native-community/viewpager": "^3.3.0",
"prop-types": "^15.5.10"
},
"config": {
Expand Down
26 changes: 16 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import {
ActivityIndicator
} from 'react-native'

import ViewPagerAndroid from '@react-native-community/viewpager';

const { width, height } = Dimensions.get('window')

/**
* Default styles
* @type {StyleSheetPropType}
Expand Down Expand Up @@ -196,13 +200,14 @@ export default class extends Component {
autoplayTimer = null
loopJumpTimer = null

componentWillReceiveProps(nextProps) {
if (!nextProps.autoplay && this.autoplayTimer)
componentWillReceiveProps (nextProps) {
if (!nextProps.autoplay && this.autoplayTimer) {
clearTimeout(this.autoplayTimer)
if (nextProps.index === this.props.index) return
this.setState(
this.initState(nextProps, this.props.index !== nextProps.index)
)
this.setState(this.initState(nextProps))
} else if(nextProps.autoplay){
this.autoplay(nextProps.autoplay);
this.loopJump();
}
}

componentDidMount() {
Expand Down Expand Up @@ -344,10 +349,11 @@ export default class extends Component {
/**
* Automatic rolling
*/
autoplay = () => {
if (
!Array.isArray(this.state.children) ||
!this.props.autoplay ||

autoplay = (autoplay) => {
const toggleAutoplay = this.props.autoplay || autoplay;
if (!Array.isArray(this.props.children) ||
!toggleAutoplay ||
this.internals.isScrolling ||
this.state.autoplayEnd
)
Expand Down

0 comments on commit f6c6a3c

Please sign in to comment.