Giter Club home page Giter Club logo

Comments (5)

davidsamacoits avatar davidsamacoits commented on May 24, 2024

@minhtamwebmaster Not supported currently but will definitely be part of a next release.

from react-native-swipeable-parallax-carousel.

danielMensah avatar danielMensah commented on May 24, 2024

@minhtamwebmaster I've found a work around, might help.

Start by adding a global varriable var timer;

Add an interval to the constructor:

    if (this.props.autoPlay) {
      timer = setInterval(() => {
        this._forceSwipe('left');
      }, this.props.playTime);
    }

Also need to clearInterval :

  componentWillUnmount() {
    clearInterval(timer);
  }

Then change _forceSwipe() to:

  _forceSwipe(direction) {
    const { autoPlay } = this.props;
    let distance = (direction === 'right') ? this.state.screenWidth : -this.state.screenWidth;
    // Calculate nextItem
    const currentitem = this.state.currentItem;
    const totalItems = this.props.data.length;
    let newitem = (direction === 'right') ? currentitem - 1 : currentitem + 1;

    if (autoPlay && newitem === totalItems) {
      distance = this.state.screenWidth * (totalItems - 1);
      newitem = 0;
    }

    this.setState({ nextItem: newitem });
    Animated.spring(this.position, {
      toValue: { x: distance, y: 0 },
    }).start(() => this._onSwipeComplete(newitem));
  }

And then you can add the props to the Carousel component like this:

<Carousel
            data={dataCarousel}
            parentScrollViewRef={this.parentScrollView}
            autoPlay={true}
            playTime={5000}
            navigationType="bars"/>

If you want I can try to commit it.

from react-native-swipeable-parallax-carousel.

minhtamwebmaster avatar minhtamwebmaster commented on May 24, 2024

from react-native-swipeable-parallax-carousel.

danielMensah avatar danielMensah commented on May 24, 2024

@minhtamwebmaster Since I have no permission to commit anything to this repo, I have created a node is module for this myself.

https://github.com/danielMensah/react-native-smart-carousel

from react-native-swipeable-parallax-carousel.

geminiyellow avatar geminiyellow commented on May 24, 2024

@davidsamacoits this repo still working?

from react-native-swipeable-parallax-carousel.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.