Skip to content

Commit f6c6a3c

Browse files
authored
Merge pull request leecade#1 from Akarsh08/fix/onTouchHandle
Fix/on touch handle
2 parents 9e50938 + 9ec45bd commit f6c6a3c

File tree

3 files changed

+65
-10
lines changed

3 files changed

+65
-10
lines changed

package-lock.json

+48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"updtr": "^2.0.0"
6161
},
6262
"dependencies": {
63+
"@react-native-community/viewpager": "^3.3.0",
6364
"prop-types": "^15.5.10"
6465
},
6566
"config": {

src/index.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import {
1515
ActivityIndicator
1616
} from 'react-native'
1717

18+
import ViewPagerAndroid from '@react-native-community/viewpager';
19+
20+
const { width, height } = Dimensions.get('window')
21+
1822
/**
1923
* Default styles
2024
* @type {StyleSheetPropType}
@@ -196,13 +200,14 @@ export default class extends Component {
196200
autoplayTimer = null
197201
loopJumpTimer = null
198202

199-
componentWillReceiveProps(nextProps) {
200-
if (!nextProps.autoplay && this.autoplayTimer)
203+
componentWillReceiveProps (nextProps) {
204+
if (!nextProps.autoplay && this.autoplayTimer) {
201205
clearTimeout(this.autoplayTimer)
202-
if (nextProps.index === this.props.index) return
203-
this.setState(
204-
this.initState(nextProps, this.props.index !== nextProps.index)
205-
)
206+
this.setState(this.initState(nextProps))
207+
} else if(nextProps.autoplay){
208+
this.autoplay(nextProps.autoplay);
209+
this.loopJump();
210+
}
206211
}
207212

208213
componentDidMount() {
@@ -344,10 +349,11 @@ export default class extends Component {
344349
/**
345350
* Automatic rolling
346351
*/
347-
autoplay = () => {
348-
if (
349-
!Array.isArray(this.state.children) ||
350-
!this.props.autoplay ||
352+
353+
autoplay = (autoplay) => {
354+
const toggleAutoplay = this.props.autoplay || autoplay;
355+
if (!Array.isArray(this.props.children) ||
356+
!toggleAutoplay ||
351357
this.internals.isScrolling ||
352358
this.state.autoplayEnd
353359
)

0 commit comments

Comments
 (0)