Skip to content

Commit

Permalink
Use this._autoplay instead of props.autoplay
Browse files Browse the repository at this point in the history
  • Loading branch information
HelloCore committed Oct 5, 2019
1 parent f645204 commit b989fd0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/carousel/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ export default class Carousel extends Component {

// `onTouchStart` is fired even when `scrollEnabled` is set to `false`
if (this._getScrollEnabled() !== false && this._autoplaying) {
this.stopAutoplay();
this.pauseAutoPlay();
}

if (onTouchStart) {
Expand All @@ -847,7 +847,7 @@ export default class Carousel extends Component {
_onTouchEnd () {
const { onTouchEnd } = this.props

if (this._getScrollEnabled() !== false && autoplay && !this._autoplaying) {
if (this._getScrollEnabled() !== false && this._autoplay && !this._autoplaying) {
// This event is buggy on Android, so a fallback is provided in _onScrollEnd()
this.startAutoplay();
}
Expand Down Expand Up @@ -902,7 +902,7 @@ export default class Carousel extends Component {
}

_onScrollEnd (event) {
const { autoplay, autoplayDelay, enableSnap } = this.props;
const { autoplayDelay, enableSnap } = this.props;

if (this._ignoreNextMomentum) {
// iOS fix
Expand All @@ -919,7 +919,7 @@ export default class Carousel extends Component {

// The touchEnd event is buggy on Android, so this will serve as a fallback whenever needed
// https://github.com/facebook/react-native/issues/9439
if (autoplay && !this._autoplaying) {
if (this._autoplay && !this._autoplaying) {
clearTimeout(this._enableAutoplayTimeout);
this._enableAutoplayTimeout = setTimeout(() => {
this.startAutoplay();
Expand Down Expand Up @@ -1081,6 +1081,7 @@ export default class Carousel extends Component {

startAutoplay () {
const { autoplayInterval, autoplayDelay } = this.props;
this._autoplay = true;

if (this._autoplaying) {
return;
Expand All @@ -1097,9 +1098,14 @@ export default class Carousel extends Component {
}, autoplayDelay);
}

stopAutoplay () {
pauseAutoPlay () {
this._autoplaying = false;
clearInterval(this._autoplayInterval);
clearInterval(this._autoplayInterval);
}

stopAutoplay () {
this._autoplay = false;
this.pauseAutoPlay();
}

snapToItem (index, animated = true, fireCallback = true) {
Expand Down

0 comments on commit b989fd0

Please sign in to comment.