Skip to content

Commit d50e67b

Browse files
authored
Merge pull request leecade#1 from sailplaneTW/master
Support autoplay pause -> resume
2 parents cabf42a + 0f63766 commit d50e67b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"react-native",
66
"ios"
77
],
8-
"version": "1.5.4",
8+
"version": "1.5.6",
99
"description": "Swiper component for React Native.",
1010
"main": "index.js",
1111
"scripts": {

src/index.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ export default class extends Component {
167167
const sizeChanged = (nextProps.width || width) !== this.state.width ||
168168
(nextProps.height || height) !== this.state.height
169169
if (!nextProps.autoplay && this.autoplayTimer) clearTimeout(this.autoplayTimer)
170+
171+
if (nextProps.autoplay) this.autoplay(true);
172+
170173
this.setState(this.initState(nextProps, sizeChanged))
171174
}
172175

@@ -245,11 +248,11 @@ export default class extends Component {
245248
/**
246249
* Automatic rolling
247250
*/
248-
autoplay = () => {
249-
if (!Array.isArray(this.props.children) ||
251+
autoplay = (forceAutoPlay=false) => {
252+
if (!forceAutoPlay && (!Array.isArray(this.props.children) ||
250253
!this.props.autoplay ||
251254
this.internals.isScrolling ||
252-
this.state.autoplayEnd) return
255+
this.state.autoplayEnd)) return
253256

254257
this.autoplayTimer && clearTimeout(this.autoplayTimer)
255258
this.autoplayTimer = setTimeout(() => {

0 commit comments

Comments
 (0)