Skip to content

Commit

Permalink
Merge pull request leecade#1 from sailplaneTW/master
Browse files Browse the repository at this point in the history
Support autoplay pause -> resume
  • Loading branch information
irvingdp authored Feb 7, 2017
2 parents cabf42a + 0f63766 commit d50e67b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"react-native",
"ios"
],
"version": "1.5.4",
"version": "1.5.6",
"description": "Swiper component for React Native.",
"main": "index.js",
"scripts": {
Expand Down
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ export default class extends Component {
const sizeChanged = (nextProps.width || width) !== this.state.width ||
(nextProps.height || height) !== this.state.height
if (!nextProps.autoplay && this.autoplayTimer) clearTimeout(this.autoplayTimer)

if (nextProps.autoplay) this.autoplay(true);

this.setState(this.initState(nextProps, sizeChanged))
}

Expand Down Expand Up @@ -245,11 +248,11 @@ export default class extends Component {
/**
* Automatic rolling
*/
autoplay = () => {
if (!Array.isArray(this.props.children) ||
autoplay = (forceAutoPlay=false) => {
if (!forceAutoPlay && (!Array.isArray(this.props.children) ||
!this.props.autoplay ||
this.internals.isScrolling ||
this.state.autoplayEnd) return
this.state.autoplayEnd)) return

this.autoplayTimer && clearTimeout(this.autoplayTimer)
this.autoplayTimer = setTimeout(() => {
Expand Down

0 comments on commit d50e67b

Please # to comment.