Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoPlay fucntion? #11

Closed
AndriusDK opened this issue Mar 1, 2019 · 2 comments
Closed

AutoPlay fucntion? #11

AndriusDK opened this issue Mar 1, 2019 · 2 comments

Comments

@AndriusDK
Copy link

Is it possible to make it slider automatically after some time?

@lucaspelloni2
Copy link

Not sure if this feature has been implemented yet.
I implemented my own autoPlay function based on the props that are given.

class Gallery extends Component<{}, State> {
  state = {
    selected: 0,
    intervalId: 0,
    interval: 5000,
    totalImages: 2
  };

  componentWillUnmount(): void {
    clearInterval(this.state.intervalId);
  }

  timer(): void {
    let selected = (this.state.selected + 1) % this.state.totalImages;
    this.setState({ selected });
  }

  render() {
    return (
      <AwesomeSlider
        infinite={true}
        selected={this.state.selected}
        onFirstMount={() => {
          const intervalId = setInterval(
            this.timer.bind(this),
            this.state.interval
          );
          this.setState({ intervalId });
        }}
      >
        <div data-src="assets/images/1.jpg" />
        <div data-src="assets/images/2.jpg" />
      </AwesomeSlider>
    );
  }
}

export default Gallery;

@rcaferati
Copy link
Owner

Something like what @lucaspelloni2 said could work. The idea for now it to maintain the core component with a contained number of functionalities.

I'll add a HOC recipe with an infinite example before v1. Thanks @AndriusDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants