From 69622ede2bea670de1f2d3276f02f1fa930ebce3 Mon Sep 17 00:00:00 2001 From: Akarsh Srivastava Date: Mon, 3 Feb 2020 18:48:13 +0530 Subject: [PATCH 1/2] fixed: weird index behaviour on autoplay change --- src/index.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index e32fe10f..80e7c184 100644 --- a/src/index.js +++ b/src/index.js @@ -184,8 +184,13 @@ export default class extends Component { loopJumpTimer = null componentWillReceiveProps (nextProps) { - if (!nextProps.autoplay && this.autoplayTimer) clearTimeout(this.autoplayTimer) - this.setState(this.initState(nextProps)) + if (!nextProps.autoplay && this.autoplayTimer) { + clearTimeout(this.autoplayTimer) + this.setState(this.initState(nextProps)) + } else if(nextProps.autoplay){ + this.autoplay(nextProps.autoplay); + this.loopJump(); + } } componentDidMount () { @@ -271,9 +276,10 @@ export default class extends Component { /** * Automatic rolling */ - autoplay = () => { + autoplay = (autoplay) => { + const toggleAutoplay = this.props.autoplay || autoplay; if (!Array.isArray(this.props.children) || - !this.props.autoplay || + !toggleAutoplay || this.internals.isScrolling || this.state.autoplayEnd) return From c658119e030b639045a40c12da6c865811381f8c Mon Sep 17 00:00:00 2001 From: Akarsh Srivastava Date: Mon, 3 Feb 2020 19:07:47 +0530 Subject: [PATCH 2/2] fixed: viewpager android package --- package-lock.json | 48 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + src/index.js | 3 ++- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..25221c28 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,48 @@ +{ + "name": "react-native-swiper", + "version": "1.5.10", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@react-native-community/viewpager": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/@react-native-community/viewpager/-/viewpager-3.3.0.tgz", + "integrity": "sha512-tyzh79l4t/hxiyS9QD3LRmWMs8KVkZzjrkQ8U8+8To1wmvVCBtp8BenvNsDLTBO7CpO/YmiThpmIdEZMr1WuVw==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "react-native-viewpager": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/react-native-viewpager/-/react-native-viewpager-0.2.13.tgz", + "integrity": "sha1-deQhrpDonvzXfSwHfAUlOCt8OcU=", + "requires": { + "react-timer-mixin": "^0.13.3", + "warning": "^2.1.0" + } + }, + "react-timer-mixin": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/react-timer-mixin/-/react-timer-mixin-0.13.4.tgz", + "integrity": "sha512-4+ow23tp/Tv7hBM5Az5/Be/eKKF7DIvJ09voz5LyHGQaqqz9WV8YMs31eFvcYQs7d451LSg7kDJV70XYN/Ug/Q==" + }, + "warning": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/warning/-/warning-2.1.0.tgz", + "integrity": "sha1-ISINnGOvx3qMkhEeARr3Bc4MaQE=", + "requires": { + "loose-envify": "^1.0.0" + } + } + } +} diff --git a/package.json b/package.json index dbef24a6..8e810949 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "updtr": "^0.2.3" }, "dependencies": { + "@react-native-community/viewpager": "^3.3.0", "prop-types": "^15.5.10" } } diff --git a/src/index.js b/src/index.js index 80e7c184..698d0842 100644 --- a/src/index.js +++ b/src/index.js @@ -11,11 +11,12 @@ import { ScrollView, Dimensions, TouchableOpacity, - ViewPagerAndroid, Platform, ActivityIndicator } from 'react-native' +import ViewPagerAndroid from '@react-native-community/viewpager'; + const { width, height } = Dimensions.get('window') /**